Page 154 - ComputerScience_Class_11
P. 154
3. What will Amit's total income for the month be, including his salary and performance bonus?
a. ₹52,500 b. ₹53,000
c. ₹54,000 d. ₹55,000
4. What arithmetic operation does Amit use to calculate his total income for the month?
a. + (Addition) b. - (Subtraction)
c. * (Multiplication) d. / (Division)
F. Write the java program for the following:
1. Write a program to display the division result of two integers as a floating-point number. The output should be as follows:
Division Result: 3.0
2. Write a program to convert a string representation of an integer and a string representation of a floating-point number to their
respective primitive types using wrapper classes. The program should produce the following output:
Converted Integer: 100
Converted Double: 10.5
3. Write a program that asks the user to input two numbers. The program should calculate and display their average. The output
should be as follows:
Enter two numbers:
25
16
Average : 20.5
G. Find the output of the following programs:
1. import java.util.Scanner;
public class DiscountCalculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the original price: ");
double originalPrice = sc.nextDouble();
System.out.print("Enter the discount percentage: ");
double discountPercentage = sc.nextDouble();
if (discountPercentage < 0) {
System.out.println("Discount cannot be negative!");
return;
}
double discountAmount = (originalPrice * discountPercentage) / 100;
double finalPrice = originalPrice - discountAmount;
System.out.println("Discount Amount: " + discountAmount);
System.out.println("Final Price: " + finalPrice);
}
}
2. public class ImplicitConversion {
public static void main(String[] args) {
int intValue = 25;
double doubleValue = intValue;
char ch = 'A';
int asciiValue = ch;
float floatValue = intValue;
System.out.println("Integer value: " + intValue);
152 Touchpad Computer Science (Ver. 3.0)-XI

