Java programs for beginners
A computer salesman gets commission on the following basis:Sales Commission RateRs. 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
Java programs for beginners
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


Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.