7 Replies - 1358 Views - Last Post: 31 March 2012 - 08:06 AM Rate Topic: -----

#1 skyza  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-March 12

What is wrong with my C++ program?

Posted 30 March 2012 - 09:54 PM

This is my assignment:

Write a menu-driven program that will allow the user to select 1 item from Chuckie's Kitchen Hot Sandwiches, 1 additional side order item, and 1 beverage. The program should compute the total and print the amount of the user's total bill (formatted to two decimal points). Implement your menu logic using either if /else if blocks or a switch blocks.

This is the menu:
http://i231.photobuc...itchen_menu.jpg

Posted Image


Here's my program, can you tell me how to fix it please?




#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
const int MAIN_DISH = 8 pcs wings, 10 pcs wings, 12 pcs wings, 15 pcs wings, 20 pcs wings, chili dog, fish fry, chicken breast, bbq rib boneless, bacon burger, cheeseburger, turkey burger, double burger, turkey, roast beef, ham & cheese, tuna, deluxe mix

const int SIDE_ORDER = french fries, onion rings, macaroni & cheese, cole slaw

const int BEVERAGE = pepsi, orange, mountain dew, root beer, water, sierra mist, orange juice, apple juice


8 pcs wings = 4.50
10 pcs wings = 5.00
12 pcs wings = 5.70
15 pcs wings = 6.70
20 pcs wings = 8.75
chili dog = 2.50
fish fry = 4.95
chicken breast = 4.95
bbq rib = 5.95
bacon burger = 4.95
cheeseburger = 3.95
turkey burger = 3.95
double burger = 5.95
turkey = 2.50
roast beef = 4.95
ham & cheese = 4.95
tuna = 3.95
deulxe mix = 4.95

french fries = 2.50
onion rings = 2.75
macaroni & cheese = 2.50
cole slaw = 2.25

pepsi = 1.25
orange = 1.25
mountain dew = 1.25
root beer = 1.25
water = 1.00
sierra mist = 1.25
orange juice = 1.50
apple juice = 1.50




cout << "Enter an item: ";
cin >> MAIN_DISH;

cout << "Enter a side order: ";
cin >> SIDE_ORDER;

cout << "Enter a beverage: ";
cin >> BEVERAGE;


cin >> MAIN_DISH + SIDE_ORDER + BEVERAGE;

return ("pause");

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: What is wrong with my C++ program?

#2 skyza  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-March 12

Re: What is wrong with my C++ program?

Posted 30 March 2012 - 10:20 PM

Okay, I've fixed a few things (I think)



#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
const int MAIN_DISH = eight_pcs_wings, ten_pcs_wings, twelve_pcs_wings, fifteen_pcs_wings, twenty_pcs_wings, chili_dog, fish_fry, chicken_breast, bbq_rib, bacon_burger, cheeseburger, turkey_burger, double-burger, turkey, roast_beef, ham_&_cheese, tuna, deluxe_mix

const int SIDE_ORDER = french fries, onion rings, macaroni & cheese, cole slaw

const int BEVERAGE = pepsi, orange, mountain dew, root beer, water, sierra mist, orange juice, apple juice


8 pcs wings = 4.50
10 pcs wings = 5.00
12 pcs wings = 5.70
15 pcs wings = 6.70
20 pcs wings = 8.75
chili dog = 2.50
fish fry = 4.95
chicken breast = 4.95
bbq rib = 5.95
bacon burger = 4.95
cheeseburger = 3.95
turkey burger = 3.95
double-burger = 5.95
turkey = 2.50
roast beef = 4.95
ham & cheese = 4.95
tuna = 3.95
deulxe mix = 4.95

french fries = 2.50
onion rings = 2.75
macaroni & cheese = 2.50
cole slaw = 2.25

pepsi = 1.25
orange = 1.25
mountain dew = 1.25
root beer = 1.25
water = 1.00
sierra mist = 1.25
orange juice = 1.50
apple juice = 1.50




cout << "Enter an item: ";
cin >> MAIN_DISH;

cout << "Enter a side order: ";
cin >> SIDE_ORDER;

cout << "Enter a beverage: ";
cin >> BEVERAGE;


cin >> MAIN_DISH + SIDE_ORDER + BEVERAGE;

return ("pause");


Was This Post Helpful? 0
  • +
  • -

#3 skyza  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-March 12

Re: What is wrong with my C++ program?

Posted 30 March 2012 - 10:36 PM

Whoops. Okay NOW I've fixed the things I know how to.


#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
const int MAIN_DISH = eight_pcs_wings, ten_pcs_wings, twelve_pcs_wings, fifteen_pcs_wings, twenty_pcs_wings, chili_dog, fish_fry, chicken_breast, bbq_rib, bacon_burger, cheeseburger, turkey_burger, double_burger, turkey, roast_beef, ham_&_cheese, tuna, deluxe_mix

const int SIDE_ORDER = french fries, onion rings, macaroni & cheese, cole slaw

const int BEVERAGE = pepsi, orange, mountain dew, root beer, water, sierra mist, orange juice, apple juice


eight pcs wings = 4.50
ten pcs wings = 5.00
twelve pcs wings = 5.70
fifteen pcs wings = 6.70
twenty pcs wings = 8.75
chili dog = 2.50
fish fry = 4.95
chicken breast = 4.95
bbq rib = 5.95
bacon burger = 4.95
cheeseburger = 3.95
turkey burger = 3.95
double_burger = 5.95
turkey = 2.50
roast beef = 4.95
ham & cheese = 4.95
tuna = 3.95
deulxe mix = 4.95

french fries = 2.50
onion rings = 2.75
macaroni & cheese = 2.50
cole slaw = 2.25

pepsi = 1.25
orange = 1.25
mountain dew = 1.25
root beer = 1.25
water = 1.00
sierra mist = 1.25
orange juice = 1.50
apple juice = 1.50




cout << "Enter an item: ";
cin >> MAIN_DISH;

cout << "Enter a side order: ";
cin >> SIDE_ORDER;

cout << "Enter a beverage: ";
cin >> BEVERAGE;


cin >> MAIN_DISH + SIDE_ORDER + BEVERAGE;

return ("pause");




It's still showing errors. How can I fix this?
Was This Post Helpful? 0
  • +
  • -

#4 Salem_c  Icon User is online

  • void main'ers are DOOMED
  • member icon

Reputation: 1678
  • View blog
  • Posts: 3,180
  • Joined: 30-May 10

Re: What is wrong with my C++ program?

Posted 31 March 2012 - 12:03 AM

Well before you rush off to try and write a whole program, start with something simple.

Imagine a menu with only two items on it (say "sandwich" and "pepsi").
#include <iostream>
#include <string>
using namespace std;
int main ( ) {
    string menuItems[] = { "sandwich", "pepsi" };
    double menuPrices[] = { 2.50, 1.25 );
    return 0;
}


Now, some easy exercises for you to do
- write a loop to print out the menu and associated price.
- write code to prompt the user for their menu choice(s), and how many of each item they want.
- print out their choices, amounts and total.

Done properly, adding the rest of the menu is a 5 minute job.
Done badly, it's copy/pasting the same mistake over and over.

All you've really done so far is copy/paste the menu text and thrown in a few C++ keywords without any understanding of what's going on.


http://www.cplusplus...beginner/66056/
Was This Post Helpful? 0
  • +
  • -

#5 skyza  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 30-March 12

Re: What is wrong with my C++ program?

Posted 31 March 2012 - 12:54 AM

So would I replace "sandwich" and "pepsi" with my menu items? And the prices with the price of the menu item in order?
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,518
  • Joined: 23-August 08

Re: What is wrong with my C++ program?

Posted 31 March 2012 - 03:03 AM

Did you find someone to do your other program for you?
Was This Post Helpful? 0
  • +
  • -

#7 Salem_c  Icon User is online

  • void main'ers are DOOMED
  • member icon

Reputation: 1678
  • View blog
  • Posts: 3,180
  • Joined: 30-May 10

Re: What is wrong with my C++ program?

Posted 31 March 2012 - 04:14 AM

> So would I replace "sandwich" and "pepsi" with my menu items?
Or perhaps
    string menuItems[] = { "Aircraft carrier", "jumbo jet" };
    double menuPrices[] = { 2.50E10, 1.25E9 );


The menu content at this point is irrelevant.

There are only 3 numbers in computing which matter - zero, one and many. If your program works properly with 2(many), then it will work properly with 20(many). If you can solve it for 2, you're golden.

You have a list of things, and a list of prices for those things.

YOU need to write code that can
- display the list of things and prices
- display a choice
- read user choice (in a loop)
- print the list of user choices, amounts wanted, itemised price and total price.

Whilst you're still thinking about creating variables with "pepsi" in the name (of the variable), you're not going to get anywhere with this problem.
Was This Post Helpful? 0
  • +
  • -

#8 nunc  Icon User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 131
  • Joined: 20-November 11

Re: What is wrong with my C++ program?

Posted 31 March 2012 - 08:06 AM

And just a side note. When you go on forums, remember that the people here are using their time to help you. Nobody will give you code, regardless what forum you go to.

In situations like these, it's often best to sit down and work out what you need to do on paper. Use some logic and write down what you think needs done, and don't get caught up on irrelevant details.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1