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
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.