A bicycle shop hires bicycle on daily basis
at different rates throuout the year.
The following table shows the rate at
different season
Season
Daily Charge (Rs.)
Spring
4.00
Summer
7.00
Autumn
3.00
Winter
2.00
The proprietor gives a discount of 30% is
bicycles are hired for more than 10 days.
A security amount Rs. 1000 to be deposited for
every bicle hired. Write a program in java to input the season and number
of days hired. Display the hired charge
including deposit.
import
java.util.*;
class
Asc
{
int no;
double
discount=0,amt;
String
season;
Scanner
sc=new Scanner(System.in);
public void show()
{
System.out.print("\nEnter The
season: ");
season=sc.nextLine();
System.out.print("\nEnter Number
of days hired: ");
no=sc.nextInt();
if(season.equalsIgnoreCase("Spring"))
amt=no*4;
else
if(season.equalsIgnoreCase("Summer"))
amt=no*7;
else if(season.equalsIgnoreCase("Autumn"))
amt=no*3;
else
if(season.equalsIgnoreCase("Winter"))
amt=no*2;
if(no>10)
discount=amt*30/100;
amt=amt-discount+1000;
System.out.print("\nBilling
amount including deposit and discount: "+amt);
}
public static void main(String args[])
{
Asc ob=new Asc();
ob.show();
}
}
Sample Input Output
Enter
The season: winter
Enter
Number of days hired: 23
Billing
amount including deposit and discount: 1032.2
No comments:
Post a Comment