Professional Documents
Culture Documents
Quiz 1 Section A
Quiz 1 Section A
Spring 2022
Maximum Marks: 2.5 Instructor: Dr. Sajid Khan
Name:______________ CMS ID:__________________ Date:23/03/2022
1. Write a program in Java that allow used to input as much numbers he/she wants. However, user is
required to enter “sum”, “mul” or “ave” to end the input stream. If user enters sum it should
display sum of all numbers entered. In case if user writes mul at the end, multiplication of
numbers should be displayed. In case if ave is provided at the end, average should be displayed.
In case if you don’t remember the names of functions, you can name write any
class HelloWorld {
public static void main(String[] args) {
int a = 19, b = 20;
int c = a^b;
int d = c|b|255;
System.out.println("a&b=" + c +"\n c|b|255 = "+d);
}
}
3. Why was there a need for Java language? Define within three lines.