#### Java videos

A computer salesman gets commission on the following basis:
Sales Commission Rate
Rs. 0 – 20,000 3%
Rs. 20,000 – 50,000 12%
Rs. 50,001 and more 31%
Write a program to accept the sales as input, calculate and print his commission amount and rate of commission.

``````import java.util.*;
class Commision
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the sales amount");
int saleAmt=sc.nextInt();
int comRate=0;
float commision=0.0f;
if(saleAmt>0 && saleAmt<20000)
comRate=3;
else if(saleAmt >= 20000 && saleAmt < 50000)
comRate=12;
else
comRate=31;

commision=(comRate*saleAmt)/100;

System.out.println("The sales amount is "+saleAmt);
System.out.println("The commision rate is "+comRate);
System.out.println("The commision is "+commision);

}
}``````

Output:

Write a program in Java to input two distances and calculate their sum by applying proper adjustments.
Display the final result with an appropriate message. (Given 1 feet = 12 inches)
The sum of two distances is calculated as:
Distance 1 = 10 feets 24 inches
Distance 2 = 5 feets 16 inches
Sum of Distances= 18 feets 4 inches

``````
import java.util.*;
class Feet
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the distance in feet and inches");
int f1=sc.nextInt();
int I1=sc.nextInt();
System.out.println("Enter the distance in feet and inches");
int f2=sc.nextInt();
int I2=sc.nextInt();
int resf=f1+f2;
int resI=I1+I2;
while(resI>12)
{
resI=resI-12;
resf=resf+1;
}
System.out.println("The first distance is "+ f1+"feet"+I1+"inches");
System.out.println("The second distance is "+ f2+"feet"+I2+"inches");
System.out.println("The final distance is "+ resf+"feet"+resI+"inches");
}
}``````

Output:

#### Solved programs for class-9

SHARE
Previous articleBinary search with Recursion
Next articlePrograms for beginners class IX