Beginner Programmer Question's

Hello. I just started a Intro to C++ class, and I am having problems with my first program. Any insight would be great. I just cant seem to get it to run.

Assignment:

Ask the user for the diameter of the pizza.
• Report the number of slices that may be taken from the pizza (to one decimal place as specified
in the problem). (This is the result for problem 18.)
• Ask the user how many people will be attending the party.
• Report the number of pizzas that need to be purchased. The number reported here should be a
whole number. (This is the additional result required for problem 19.)
When your instructor tests the program, he will expect the program to flow as outlined above; i.e. he
will enter the diameter and expect to see the number of slices as output, then will enter the number of
people and expect to see the number of pizzas.
Use named constants in your program where applicable



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
47
// This program will be used to calculate the number of slices a pizza of any size can be divided into.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

	int main()
{
	long double DiameterOfPizza, NumberOfSlices, AreaOfPizza;
	long double RadiusOfPizza, PeopleAttending, PizzasPurchased;
	const double AreaPerSlice = 14.125;
	const double Pi = 3.14159;
	const double SlicesEaten = 4;

	// Ask the user for the diameter of the pizza in inches.
	cout << "What is the diameter of the pizza? (in inches) ";			// Output
	cin >> "DiameterOfPizza";											// Input

	// Calculate the number of slices that may be taken from a pizza of that size.
	cout << fixed << setprecision (3);	
	
	RadiusOfPizza = DiameterOfPizza / 2;
	AreaOfPizza = Pi *sqrt(RadiusOfPizza);
	NumberOfSlices = AreaPerSlice / AreaOfPizza;
	
	// Display a message telling the number of slices.
	cout << fixed << setprecision (3);									// Sets decimal place to .001
	cout << " The pizza has "<< NumberOfSlices << endl;					// Output
	
	// Ask the user how many people will be attending the party.
	cout << "How many people will be attending the party? ";
	cin >> "PeopleAttending";

	// Ask what size diameter pizzas will be ordered.
	cout << "What size diamter pizzas will be ordered? ";
	cin >> "DiameterOfPizza ";

	// Calculate the number of pizzas needed to be purchased.
	PizzasPurchased = PeopleAttending * (SlicesEaten / NumberOfSlices)

	// Display the number of pizzas needing to be purchased.
	;cout << " This many pizzas must be ordered " << PizzasPurchased << endl;

	system("pause");
	return 0;

}





Error Message:

c:\program files\microsoft visual studio 10.0\vc\include\istream(466): or 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::operator >>(std::basic_streambuf<_Elem,_Traits> *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
Last edited on
1
2
3
4
// Ask the user for the diameter of the pizza in inches.
cout << "What is the diameter of the pizza? (in inches) "; // Output
//cin >> "DiameterOfPizza"; // Input
cin >> DiameterOfPizza;	 // Input 


And likewise for input of the other variables.
(Do not put quotes around names of variables.)
Made some alterations. Thank you so much. I just cant figure out the problem I am having with my math.

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
47
48
49

// This program will be used to calculate the number of slices a pizza of any size can be divided into.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

	int main()
{
	double DiameterOfPizza, NumberOfSlices, AreaOfPizza;
	double RadiusOfPizza, PeopleAttending, PizzasPurchased;
	const double AreaPerSlice = 14.125;
	const double Pi = 3.14159;
	const double SlicesEaten = 4;

	// Ask the user for the diameter of the pizza in inches.
	cout << "What is the diameter of the pizza? (in inches) ";			// Output
	cin >> DiameterOfPizza ;											// Input

	// Calculate the number of slices that may be taken from a pizza of that size.
	cout << fixed << setprecision (3);	
	
	RadiusOfPizza = DiameterOfPizza / 2;
	AreaOfPizza = Pi * RadiusOfPizza * RadiusOfPizza;
	NumberOfSlices = AreaPerSlice / AreaOfPizza;
	
	// Display a message telling the number of slices.
	cout << fixed << setprecision (3);									// Sets decimal place to .001
	cout << "The pizza has "<< NumberOfSlices << "slices." << endl;					// Output
	
	// Ask the user how many people will be attending the party.
	cout << "How many people will be attending the party? ";
	cin >>  PeopleAttending ;

	// Ask what size diameter pizzas will be ordered.
	cout << "What size diameter pizzas will be ordered? ";
	cin >>  DiameterOfPizza ;

	// Calculate the number of pizzas needed to be purchased.
	PizzasPurchased = PeopleAttending * (SlicesEaten / NumberOfSlices);

	// Display the number of pizzas needing to be purchased.
	cout << PizzasPurchased << " pizzas must be ordered. " << endl;

	system("pause");
	return 0;

}
Answered my own question!
Topic archived. No new replies allowed.