| Lakers10 (5) | |
|
//Program that displays States and shipping prices # include <iostream> using namespace std; int main () { //Declare Variable int state1= AL; int state2= GA; int state3= FL; int state4= MS; int state5= LA ; int state6= TN; //Display to Screen cout<<"Alabama"<< endl; cin>> State1; cout<<"Georgia"<<endl; cin>> State2; cout<<"Florida"<< endl; cin>> State3; cout<<"Mississippi"<<endl; cin>> State4; cout<<"Louisiana"<<endl; cin>> State5; cout<<"Tennessee"<<endl; cin>> State6; If (shipping price >=$15) cout<<"Montgomery, Alabama, flower Camellia, Cotton State"<<endl; else if(shipping price >=$25) cout<<"Atlanta, Georgia, flower Cherokee Rose, Peach State"<<endl; If (shipping price >=$35) cout<<"Tallahassee, Florida, flower Orange Blossom, Sunshine State"<<endl; else if(shipping price >=$45) cout<<"Jackson, Mississippi, flower Magnolia, MS Magnolia State"<<endl; If (shipping price >=$55) cout<<"Baton Rouge, Louisiana, flower Magnolia, Bayou State"<<endl; else if(shipping price >=$65) cout<<"Nashville, Tennessee, flower Iris, Volunteer State"<<endl; int x; cin>> x; return 0; } | |
|
|
|
| Bazzy (6275) | |
|
Which are the problems? http://www.cplusplus.com/articles/firedraco1/ | |
|
|
|
| Lakers10 (5) | |
|
Determine and produce the code that will take in capital and lowercase abbreviations for states (Alabama, Georgia, Florida, Mississippi, Louisiana, and Tennessee) from the user in order to determine their shipping prices (15, 25, 35, 45, 55, 65) respectively. The prices as well as the state’s name, capital name, state flower, and the state’s nickname should appear on the screen. (shows how to accept input from user, how to use logic operands, selection, and ability to access other resources) my profesor says its wrong? | |
|
|
|
| killemall77777 (9) | |
|
Well, the first thing I saw is that you can't initialize ints with characters... What I would suggest is creating a struct for states that contains variables for everything you need. Then you can overload the << operator to be able to output all that information when you cout<< them. Does that help? | |
|
Last edited on
|
|
| killemall77777 (9) | |||
Here's some pseudo-code to help you out:
This may be a little overcomplicated for an assignment like this, but I hope it helped. | |||
|
Last edited on
|
|||
| kibestar (42) | |||||||||
Before anything, I would advise you to read the whole first and second sections of this site's tutorial. The errors I can find by looking:
You aren't declaring here, you're initializing them also, with invalid data types. Since it's an int, it can't hold text, such as AL or GA. You should use a string or char array.
I don't know why would you want somewone to input something here, since it's only to display, plus, all those variables aren't declared.
First, if isn't If. Second, you are using undeclared variables, the "shipping price", plus a variable name can't have blank spaces.Third, you are using "shipping price >=$15". The compiler isn't up to date on the world's finances, and won't understand "$" as a notation for money. You have to use 15 only. Fourth, you are using several if... else if then if.... else if. You should use one if, and the rest else if, and an else. Fifth, int x; cin >>x; For what? If you want to pause the program then use system("pause") (ONLY if you aren't distributing this code). Otherwise use an ininite loop, such as:
Hope I helped. | |||||||||
|
|
|||||||||
| Lakers10 (5) | |
| Thanks | |
|
|
|
| Lakers10 (5) | |
| But what code i can use? | |
|
|
|