Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-12-2008, 12:27 AM
Member
 
Join Date: Oct 2008
Posts: 36
Rep Power: 0
icedragon770 is on a distinguished road
Default Question/Java Program
this is logic not java but needs to put in java program which im doing ?
Quote:
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
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-12-2008, 12:29 AM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 3,190
Rep Power: 5
Fubarable is on a distinguished road
Default
Quote:
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 12:31 AM.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-12-2008, 12:31 AM
Member
 
Join Date: Oct 2008
Posts: 36
Rep Power: 0
icedragon770 is on a distinguished road
Default
no its just the whole problem. do u need me to show my java or not?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-12-2008, 03:28 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
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?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 10-12-2008, 07:27 PM
Member
 
Join Date: Oct 2008
Posts: 36
Rep Power: 0
icedragon770 is on a distinguished road
Default
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
Quote:
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 07:32 PM.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 10-12-2008, 08:08 PM
Senior Member
 
Join Date: Sep 2008
Posts: 607
Rep Power: 1
Darryl.Burke is on a distinguished road
Default
A variable can be declared only once in the same scope.

db
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 10-12-2008, 08:16 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 10-13-2008, 06:12 AM
Member
 
Join Date: Oct 2008
Posts: 36
Rep Power: 0
icedragon770 is on a distinguished road
Default
i found it and was my mistake
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Question Jay-1.1 New To Java 11 05-01-2008 04:04 PM
A core java Question chravikumar008 New To Java 2 04-21-2008 08:04 AM
How to execute an External Program through Java program Java Tip java.io 0 04-04-2008 02:40 PM
Java Pacman question whdbstjr90 New To Java 0 12-11-2007 11:28 PM
How to execute an External Program through Java program JavaBean Java Tips 0 10-04-2007 09:33 PM


All times are GMT +2. The time now is 05:42 PM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org