HELP PLEASE

Using selection criteria method, construct a program to output the following total cost in each case.
i. If vitamins sold <=20 and cost is 0.05 pence per vitamin.
ii. If vitamins sold between 21 and 49 inclusive then cost is 0.04 pence per vitamin.
iii. If vitamins sold >49 then cost is 0.03 pence per vitamin


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  // Filename: PROJECT7. CPP
// Uses a switch statement to control a user's selection. 

#include "stdafx.h"
#include <iostream>
#include<iomanip>
#include <stdio.h>

using namespace std;

void main()
{
int menu;
float charge = 0.00;	 // Holds total charge

cout << "** Computer Repair Center **\n\n";
cout << "What work was performed? Here are the choices: \n\n";
cout <<"\t1. Replaced the CPU and RAM\n";
cout <<"\t2. Replaced the RAM only\n";
cout <<"\t3. Repaired the monitor\n";
cout <<"\t4. Fixed stuck keys\n";

do
{
cout << "\nwhat work was performed?";
cin >> menu;
}while ((menu < 1) || (menu > 4));

// Store charge based on the repair person's input 
switch (menu)
{
case (1): {charge =  200.00; }   // Notice no break here 
case (2): {charge += 150.00; break;}
case (3): {charge =  75.00;  break;}
case (4): {charge =  12.00;  break;}
}

// Print.the results
cout << setprecision(2);
cout.setf(ios::showpoint);
cout.setf(ios::fixed);
cout << "\nthe total charge is $" << charge << "\n\n"; 
system("pause");
return;
}


I have no idea where to input the numbers given on the question and how to multiply them so if anyone kind enough to help me please would really helpful
closed account (iAk3T05o)
Remove the first #include (select empty project in the setup)
void main()?
What's the parentheses in the switch cases for, case (1) etc. And why do you end the break statements with '}'
thanks for you reply Nathan if you look the code below im trying to work out case are questions to buyers if say if someone buys vitamins 1-29 price will be 0.05
if 21 to 49 price will be 0.004
and 49 or more 0.03
if it make any sense :(

If vitamins sold <=20 and cost is 0.05 pence per vitamin.
If vitamins sold between 21 and 49 inclusive then cost is 0.04 pence per vitamin.
If vitamins sold >49 then cost is 0.03 pence per vitamin

// Filename: PROJECT7. CPP
// Uses a switch statement to control a user's selection.

#include "stdafx.h"
#include <iostream>
#include<iomanip>
#include <stdio.h>

using namespace std;

void main()
{
int menu;
float charge = 0.00; // Holds total charge

cout << "** vitamin shop **\n\n";
cout << "What work was performed? Here are the choices: \n\n";
cout <<"\t1. If vitamins sold <=20 and cost is 0.05 pence per vitamin\n";
cout <<"\t2. If vitamins sold between 21 and 49 inclusive then cost is 0.04 pence per vitamin\n";
cout <<"\t3. If vitamins sold >49 then cost is 0.03 pence per vitamin\n";

do
{
cout << "\nwhat work was performed?";
cin >> menu;
}while ((menu < 1) || (menu > 3));

// Store charge based on the repair person's input
switch (menu)
{
case (1): {charge *= 0.05; } // Notice no break here
case (2): {charge *= 0.04; break;}
case (3): {charge *= 0.03; break;}
}

// Print.the results
cout << setprecision(2);
cout.setf(ios::showpoint);
cout.setf(ios::fixed);
cout << "\nthe total charge is $" << charge << "\n\n";
system("pause");
return;
}
I have no idea why my tutor used break I just changed the word and numbers.
say if i want to buy 20 vitamins i want the 20 to * with 0.05 and get me the result's if you know what im trying to say
You are going to want to use if/else statements here instead of a switch. You can look here for more info on both statements if you are confused: http://www.cplusplus.com/doc/tutorial/control/

I would start the program off by asking the user how many vitamins they would like to buy. Then you can use if/else to find out which price they get (i.e
1
2
3
4
5
if(number < 21)
//Code for price 1
else if(number <50)
//Next statement 
//etc. 


Also use int main() instead of void main() http://www.cplusplus.com/forum/beginner/19979/
thanks a lot mate :)
Yes solution is helpful for me also. but i stuck in .net i used else if condition resolve the problem.
Thank You
Fix My Computer Dude
Topic archived. No new replies allowed.