Query 4
Query 4
import java.util.*;
class bill
{
public static void main ( )
{
Scanner sc = new Scanner (System.in);
int nw;
double ch;
System.out.println ( “Enter No of Words “);
nw=sc.nextInt( );
if (nw<=15) …………………………………………… 1
ch=15;
else if (nw>15 && nw<=25) …………………………………………… 2
ch=15 + ((nw-15)*1.50);
else …………………………………………… 3
ch=15 + (10*1.50) + ((nw-25)*1);
System.out.println(“charge = “+ch);
}
}
import java.util.*;
class bill
{
public static void main ( )
{
Scanner sc = new Scanner (System.in);
int ng;
double ch;
1 Prepared by:- Raj Kumar Jain
System.out.println ( “Enter No of Gallons “);
ng=sc.nextInt( );
if (ng<=1000) …………………………………………… 1
ch=ng*0.25;
else if (ng>1000 && ng<=3500) …………………………………………… 2
ch=(1000*0.25) + ((ng-1000)*0.50);
else if (ng>3500 && ng<=8500) …………………………………………… 3
ch=(1000*0.25) + (2500*0.50) + ((ng-3500)*0.75);
else …………………………………………… 4
ch=(1000*0.25) + (2500*0.50) + (5000*0.75)+((ng-8500)*0.90);
System.out.println(“charge = “+ch);
}
}
Q.6 A man is paid the hourly rate for the first 35 hours he works in a week. Thereafter he is paid 1.5 times
the hourly rate for the next 25 hours he works in a week and at twice the hourly rate for the next 20 hours
in a week. He is not allowed the work for more the 80 hours in a week. Write a program to input number
of hours and hour rate calculate and print wages.
import java.util.*;
class wages
{
public static void main ( )
{
Scanner sc = new Scanner (System.in);
int nh, hr;
double wa;
System.out.println ( “Enter No of Hours and Hour Rate “);
nh=sc.nextInt( );
hr=sc.nextInt( );
if (nh<=35) …………………………………………… 1
wa=nh*hr;
else if (nh>35 && nh<=60) …………………………………………… 2
wa=(35*hr) + ((nh-35)*(hr*1.5));
else if (nh>60 && nh<=80) …………………………………………… 3
wa=(35*hr) + (25*(hr*1.50) + (nh-60)*(hr*2));
System.out.println(“Wages = “+wa);
}
}