0% found this document useful (0 votes)
26 views

Query 4

The document contains code for 3 programs that calculate charges or wages based on input values and rates. The first program calculates telegram charges based on number of words entered. It charges Rs. 15 for the first 15 words and additional rates for words after 15. The second program calculates water bill based on number of gallons entered. It applies different rates per gallon depending on the quantity of gallons within set thresholds. The third program calculates wages based on hours worked and hourly rate. It pays regular rate for first 35 hours, 1.5 times rate for next 25 hours, and 2 times rate for next 20 hours, with a maximum of 80 hours per week.

Uploaded by

Manan Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Query 4

The document contains code for 3 programs that calculate charges or wages based on input values and rates. The first program calculates telegram charges based on number of words entered. It charges Rs. 15 for the first 15 words and additional rates for words after 15. The second program calculates water bill based on number of gallons entered. It applies different rates per gallon depending on the quantity of gallons within set thresholds. The third program calculates wages based on hours worked and hourly rate. It pays regular rate for first 35 hours, 1.5 times rate for next 25 hours, and 2 times rate for next 20 hours, with a maximum of 80 hours per week.

Uploaded by

Manan Gupta
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1 Prepared by:- Raj Kumar Jain

Query from Tiya


Q.4 Write a program to input number of words. Calculate and print telegram charges according to the
following condition.
No of words Charge
Fist 15 words Rs. 15
Next 10 words Additional Rs. 1.50 per word
Above 25 words Additional Rs. 1 per word

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);
}
}

Query from Dhairya Bansal Q.5 and Q.6


Q.5 Write a program to input number of gallons. Calculate and print total water bill according to the
following condition.
No of Gallons Rate per gallons
First 1000 gallons 0.25 per gallons
Next 2500 gallons 0.50 per gallons
Next 5000 gallons 0.75 per gallons
Above 8500 gallons 0.90 per gallons

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);
}
}

You might also like