# help me plz

• May 8th, 2013, 04:58 PM
shamslove03
help me plz
write a program to calculate the fare of a journey given to input-the class('A','B' or 'C') and the distance in KM.
rate is to be calculated according to the following table:
class rate for first 500 KM rate/KM after 500 KM

A 3.5 10.75
B 2.5 7.5
C 2.0 5.0

USE switch-case to write the above program logic for fare calculation.
• May 8th, 2013, 05:00 PM
Norm
Re: help me plz
• May 8th, 2013, 05:21 PM
shamslove03
Re: help me plz
write a program to calculate the fare of a journey given to input.docx

--- Update ---

any one can help me in solving this QUESTION ???
I am a new Java student ..
• May 8th, 2013, 05:55 PM
Norm
Re: help me plz
What have you tried?

• May 10th, 2013, 05:09 AM
shamslove03
Re: help me plz
i tried this >

import java.util.*;
public class calculate{
public static void main(String[]args){
Scanner Kr=new Scanner(System.in);
char Class;
double DistanceinKm,Fare1,Fare2;
System.out.println("Enter Class ");
String s=Kr.next();
Class=s.charAt(0);
System.out.println("Enter the Distance");
DistanceinKm=Kr.nextDouble();
switch(Class){
case'A':
if(DistanceinKm<500){
Fare1=3.5*DistanceinKm;
System.out.println("fare for the first 500Km=+Fare 1");
}
else
Fare1=3.5*DistanceinKm;
if(DistanceinKm>500){
Fare2=Fare1+((DistanceinKm-500)*7.5);
System.out.println("fare for after500Km="+Fare2);
}
break;
case 'B':
Fare1=2.5*DistanceinKm;
if(DistanceinKm<500){
Fare2=Fare1+((DistanceinKm-500)*7.5);
System.out.println("fare for after500Km="+Fare2);
}
break;
case'C':
if(DistanceinKm<500){
Fare1=2.0*DistanceinKm;
System.out.println("fare for after500Km="+Fare1);
}
else
Fare1=2.0*DistanceinKm;
System.out.println("fare for after500Km="+Fare1);
Fare1=2.0*DistanceinKm;
if(DistanceinKm<500){
Fare1=2.0*DistanceinKm;
System.out.println("fare for after500Km="+Fare1);
}
else
Fare1=2.0*DistanceinKm;
if(DistanceinKm>500){
System.out.println("fare for after500Km="+Fare1);
}
break;
}
}
}

waiting 4 u
• May 10th, 2013, 06:08 AM
Norm
Re: help me plz
[code=java]
[/code]
to get highlighting and preserve formatting.

Quote:

i tried this >
Post any questions you have about the problems you are having with the code.
• May 10th, 2013, 10:32 AM
shamslove03
Re: help me plz
Soory I can't understand your meaning
• May 10th, 2013, 10:44 AM
Norm
Re: help me plz