Results 1 to 8 of 8
Thread: Question/Java Program
- 10-12-2008, 12:27 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 36
- Rep Power
- 0
Question/Java Program
this is logic not java but needs to put in java program which im doing ?
just wondering do i need to initilzied the vehichle car type or not thats allStart
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
-
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).just wondering do i need to initilzied the vehichle car type or not thats all
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 12:31 AM.
- 10-12-2008, 12:31 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 36
- Rep Power
- 0
no its just the whole problem. do u need me to show my java or not?
- 10-12-2008, 03:28 AM #4
Depends on the design. A lot of apps have defaults. Some don't.do i need to initilzied the vehichle car type
what would your user prefer?
- 10-12-2008, 07:27 PM #5
Member
- Join Date
- Oct 2008
- Posts
- 36
- Rep Power
- 0
nvm about that but how bout this
this is what it said when i compile itpublic 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);
}
}
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 errorsLast edited by icedragon770; 10-12-2008 at 07:32 PM.
- 10-12-2008, 08:08 PM #6
A variable can be declared only once in the same scope.
db
- 10-12-2008, 08:16 PM #7
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.
- 10-13-2008, 06:12 AM #8
Member
- Join Date
- Oct 2008
- Posts
- 36
- Rep Power
- 0
Similar Threads
-
Java Question
By Jay-1.1 in forum New To JavaReplies: 11Last Post: 05-01-2008, 04:04 PM -
A core java Question
By chravikumar008 in forum New To JavaReplies: 2Last Post: 04-21-2008, 08:04 AM -
How to execute an External Program through Java program
By Java Tip in forum java.ioReplies: 0Last Post: 04-04-2008, 02:40 PM -
Java Pacman question
By whdbstjr90 in forum New To JavaReplies: 0Last Post: 12-11-2007, 11:28 PM -
How to execute an External Program through Java program
By JavaBean in forum Java TipReplies: 0Last Post: 10-04-2007, 09:33 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks