Level 2 practice problems
Level 2 practice problems
1. Write a program to take 2 numbers and print their quotient and reminder
import java.util.Scanner;
public class qr{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("Enter first value:");
int n1=input.nextInt();
System.out.print("Enter Second value:");
int n2=input.nextInt();
int quotient=n1/n2;
double remainder=n1%n2;
System.out.print("The quotient is :"+quotient+" and remainder
is:"+remainder+"of two number"+n1+"and"+n2);
}
}
2.Write an IntOperation program by taking a, b, and c as input values and print the
following integer operations a + b *c, a * b + c, c + a / b, and a % b + c. Please also
understand the precedence of the operators.
3.Similarly, write the DoubleOpt program by taking double values and doing the same
operations.
4.Write a Temperatue Conversion program, given the temperature in Celsius as input outputs
the temperature in Fahrenheit
5.Create a program to find the total income of a person by taking salary and bonus from user
6.Create a program to swap two numbers
7.Create variables and take user inputs for name, fromCity, viaCity, toCity
a. Create variables and take user inputs for distances fromToVia and viaToFinalCity in
Miles
b. Create Variables and take time taken
c. Finally, print the result and try to understand operator precedence.
8.Create a program to divide N number of chocolates among M children.
Hint =>
a. Get an integer value from user for the numberOfchocolates and numberOfChildren.
b. Find the number of chocolates each child gets and number of remaining chocolates
c. Display the results
9.Write a program to input the Principal, Rate, and Time values and calculate Simple Interest.
Hint => Simple Interest = Principal * Rate * Time / 100
I/P => principal, rate, time
O/P => The Simple Interest is ___ for Principal ___, Rate of Interest ___ and Time ___