Level 3 Paractice
Level 3 Paractice
Code:
import java.util.Scanner;
Output:
Question 2: Write a program that takes the temperature in Fahrenheit as input and outputs the
temperature in Celsius.
Code:
import java.util.Scanner;
Output:
Question 3: Write a program to find the total income of a person by taking salary and bonus as user
input.
Code:
import java.util.Scanner;
System.out.println("The salary is INR " + salary + " and bonus is INR " + bonus + ". Hence Total
Income is INR " + totalIncome);
Output:
The salary is INR 50000.0 and bonus is INR 5000.0. Hence Total Income is INR 55000.0
Question 4: Rewrite the Sample Program 2 with user inputs
Code:
import java.util.Scanner;
System.out.println("Total Time from Chennai to Bangalore: " + totalHours + " hours " +
remainingMinutes + " minutes");
scanner.close();
Output:
Code:
import java.util.Scanner;
number1 = number2;
number2 = temp;
System.out.println("The swapped numbers are " + number1 + " and " + number2);
Output:
Code:
import java.util.Scanner;
System.out.println("The total number of rounds the athlete will run is " + rounds + " to complete
5 km");
Output:
Question 7: Write a program to divide N chocolates among M children and display how many
chocolates each child gets and how many remain.
Code:
import java.util.Scanner;
System.out.println("The number of chocolates each child gets is " + chocolatesEach + " and the
number of remaining chocolates are " + remainingChocolates);
Output:
The number of chocolates each child gets is 6 and the number of remaining chocolates are 2
Question 8: Write a program to input the Principal, Rate, and Time values and calculate Simple
Interest.
Code:
import java.util.Scanner;
Output:
The Simple Interest is 1000.0 for Principal 10000.0, Rate of Interest 5.0 and Time 2.0
Code:
import java.util.Scanner;
System.out.println("The weight of the person in pounds is " + pounds + " and in kg is " +
kilograms);
Output:
Code:
import java.util.Scanner;
Output:
Code:
import java.util.Scanner;
System.out.println("The weight of the person in pounds is " + pounds + " and in kg is " +
kilograms);
}
}
Output: