II
II
UNSOLVED PROGRAMS:
1. Write a program to calculate and display the value of the given expression:
2 2
a + b , when a=20, b=15
a−b
class solve
c= (a*a + b*b)/(a-b);
System.out.println("Answer:" + c);
int bs = 8600;
}
3. A shopkeeper announces two successive discounts 20% and 10% on purchasing of goods at the
marked price. Write a Java program to input marked price using Scanner class. Calculate and display
the selling price of the article.
int mP = 2000;
double sp = dP2;
4. Write a Java program to input two unequal numbers. Display the numbers after swapping their
values in the variables, without using a third variable.
System.out.println("Before swapping:");
System.out.println("After swapping:");
}
5. Write a program to input the temperature in Celsius and then convert into Fahrenheit. If the
temperature in Fahrenheit is more than 98.6°F then display “Fever” otherwise “Normal”.
System.out.println("Fever");
} else {
System.out.println("Normal");
6. Write a program to accept the marks, obtained in five different subjects(English, Physics,
Chemistry, Biology, Maths) by a student and find the average marks. If the average is 80 or more,
then display he/she eligible to get “Computer Science”, otherwise “Biology”.
} else {
}
}
7. Write a program to accept the values for the principal, rate and time. Calculate and display the
interest accumulated for the first , second and the third year compounded annually.
double r = 10/100;
double I1 = P * Math.pow(1 + r, t) - P;
double A1 = P + I1;
double A2 = A1 + I2;