Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 8 of 8

Thread: help me plz

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation 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.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: help me plz

    Do you have any specific questions about your assignment?
    Please post your code and any questions about problems you are having.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    May 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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 ..

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: help me plz

    What have you tried?

    Post your code and your questions.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    May 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

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





    and I attached the question before... plz download it
    waiting 4 u

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: help me plz

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.

    i tried this >
    Post any questions you have about the problems you are having with the code.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    May 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: help me plz

    Soory I can't understand your meaning

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: help me plz

    Edit your post
    put this before the code:
    [code]

    put this after the code:
    [/code]

    --- Update ---

    Post any questions you have about the problems you are having with the code.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. help me plz
    By Epica in forum Java Servlet
    Replies: 1
    Last Post: November 28th, 2012, 09:46 AM
  2. help me up plz
    By jatinrai199 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 6th, 2011, 04:06 PM
  3. Help PLZ .. =(
    By Yazan in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 5th, 2010, 12:39 PM
  4. HELP ME HERE PLZ ... =(
    By Yazan in forum What's Wrong With My Code?
    Replies: 12
    Last Post: May 20th, 2010, 08:55 PM
  5. help me plz
    By jjhames in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 27th, 2010, 08:57 PM