Results 1 to 8 of 8
  1. #1
    icedragon770 is offline Member
    Join Date
    Oct 2008
    Posts
    36
    Rep Power
    0

    Default Question/Java Program

    this is logic not java but needs to put in java program which im doing ?
    Start

    Display a welcoming message

    Ask for the required number of passengers from 1-8

    Ask about importance of mileage on a scale of 1-10

    Ask about importance of cargo space on a scale of 1-10

    If the user entered valid answers then

    If the passenger count is 6 or more Then

    Choose the Sports Utility Vehicle (SUV)

    Else

    If mileage is more important than cargo Then

    Choose the Hybrid Sedan

    Else

    If passenger count is 5 Then

    Choose SUV

    Else

    If cargo space importance was 7 or better Then

    Choose the Pickup w/Cab

    Else

    Choose the SUV

    End If

    End If

    End If

    End If

    Tell the customer which vehicle is recommended

    Else

    Tell the customer that their entries are not correct

    End If

    Thank the customer for their interest

    Stop
    just wondering do i need to initilzied the vehichle car type or not thats all

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    just wondering do i need to initilzied the vehichle car type or not thats all
    That may be overkill. Here all you're doing is a little logic exercise and will likely be returning just a String to the user (unless this is part of a bigger program).

    Also, you may wish to choose better subject headings for your post here. Think of your subject heading as a headline for your post, something that will tell folks here in one line what to expect in the post. Very vague or overly general headings often get ignored while specific and informative headings often get the attention of someone who is an expert in this problem. Just a suggestion, YMMV.
    Last edited by Fubarable; 10-12-2008 at 01:31 AM.

  3. #3
    icedragon770 is offline Member
    Join Date
    Oct 2008
    Posts
    36
    Rep Power
    0

    Default

    no its just the whole problem. do u need me to show my java or not?

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,792
    Rep Power
    25

    Default

    do i need to initilzied the vehichle car type
    Depends on the design. A lot of apps have defaults. Some don't.
    what would your user prefer?

  5. #5
    icedragon770 is offline Member
    Join Date
    Oct 2008
    Posts
    36
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Depends on the design. A lot of apps have defaults. Some don't.
    what would your user prefer?
    nvm about that but how bout this
    public class VehicleChooser
    {
    public static void main(String args[])
    {
    // Declare and initialize variables here.
    String passengerString;
    String mileageString;
    String cargoString;
    int passengerCar;
    int mileageCar;
    int cargoSpace;
    System.out.println("Welcome to the Front Range Vehicle Center!");
    String passengerString = JOptionPane.showInputDialog("How many passenger at most will you need to carry(1-8)?");
    String mileageString = JOptionPane.showInputDialog("How important is mileage ?(On scale 1-10)?");
    String cargoString = JOptionPane.showInputDialog("How important is cargo space(On scale 1-10)?");
    passengerCar = Integer.parseInt(passengerString);
    mileageCar = Integer.parseInt(mileageString);
    cargoSpace = Integer.parseInt(cargoString);
    if ( passengerCar>=9 || passengerCar<=0)
    System.out.println( "Sorry but that is invalid passenger count");
    else if ( passengerCar>=6)
    System.out.println( "Based on your inputs, please consider our fine Sports Utility Vehicle. ");
    else if ( mileageCar>=cargoSpace)
    System.out.println( "Based on your inputs, please consider our fine Hybrid Sedan.");
    else if ( passengerCar==5)
    System.out.println( "Based on your inputs, please consider our fine Sports Utility Vehicle. ");
    else if ( cargoSpace >=7)
    System.out.println( "Based on your inputs, please consider our fine Pickup w/Cab.");
    else if ( cargoSpace>10 || cargoSpace<1)
    System.out.println( "Sorry but that is invalid Cargo Space Rating!");
    else if ( mileageCar>10 || mileageCar<1)
    System.out.println( "Sorry but that is invalid mileage rating!");
    else
    System.out.println( "Based on your inputs, please consider our fine Sports Utility Vehicle. ");
    System.out.println("Thanks for stopping by, come again soon.");


    System.exit(0);
    }
    }
    this is what it said when i compile it
    VehicleChooser.java:17: passengerString is already defined in main(java.lang.Str
    ing[])
    String passengerString = JOptionPane.showInputDialog("How many p
    assenger at most will you need to carry(1-8)?");
    ^
    VehicleChooser.java:18: mileageString is already defined in main(java.lang.Strin
    g[])
    String mileageString = JOptionPane.showInputDialog("How importan
    t is mileage ?(On scale 1-10)?");
    ^
    VehicleChooser.java:19: cargoString is already defined in main(java.lang.String[
    ])
    String cargoString = JOptionPane.showInputDialog("How important
    is cargo space(On scale 1-10)?");
    ^
    3 errors
    Last edited by icedragon770; 10-12-2008 at 08:32 PM.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,455
    Rep Power
    20

    Default

    A variable can be declared only once in the same scope.

    db

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,792
    Rep Power
    25

    Default

    Do you know what "defined" means?

    int anInt; // define a variable of type int named anInt

    A definition has the type before the variable name. Here the type is int.

  8. #8
    icedragon770 is offline Member
    Join Date
    Oct 2008
    Posts
    36
    Rep Power
    0

Similar Threads

  1. Java Question
    By Jay-1.1 in forum New To Java
    Replies: 11
    Last Post: 05-01-2008, 05:04 PM
  2. A core java Question
    By chravikumar008 in forum New To Java
    Replies: 2
    Last Post: 04-21-2008, 09:04 AM
  3. Replies: 0
    Last Post: 04-04-2008, 03:40 PM
  4. Java Pacman question
    By whdbstjr90 in forum New To Java
    Replies: 0
    Last Post: 12-12-2007, 12:28 AM
  5. Replies: 0
    Last Post: 10-04-2007, 10:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •