Two sets of code with issues

I've written these two programs and am having serious debugging issues...

I'm getting a really weird errors that have to do with the getline statement and the "=" not being a found operator for std...

And then I can get the beginning of the program to run through entering how of each cin but then it won't run the calculations.... and I feel like I wrote those calculation correctly. Am I missing something in my inclusions?

Severity Code Description Project File Line
Error C2679 binary '=': no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion) CummingsRenTipsCIS1111 c:\users\bookshelf\documents\rc_cis1111\cummingsrentips\cummingsrentipscis1111\cummingsrentipscis1111\source.cpp 64



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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Description:
develop a C++ program that calculates your bank deposit and converts a number of pennies into the 
least amount of coinage. Develop a Raptor program for Part 1 only.
*/

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

int main()
{
	double dollars, quarters, dimes, nickels, pennies;
	string name;

	cout << "Enter Account Holder's Name: ";
	getline(cin, name);
	
	cout << "Enter number of Dollars: ";
	cin >> dollars;
	cout << "Enter numer of Quarter: ";
	cin >> quarters;
	cout << "Enter numer of Dimes: ";
	cin >> dimes;
	cout << "Enter numer of Nickels: ";
	cin >> nickels;
	cout << "Enter numer of Pennies: ";
	cin >> pennies;

	double dollarsWorth = dollars * 1.00;
	double quartersWorth = quarters * .25;
	double dimesWorth = dimes * .10;
	double nickelsWorth = nickels * .05;
	double penniesWorth = pennies * .01;

	cout << "Dollars: $" << dollarsWorth <<"\n";
	cout << "Quarters: $" << quartersWorth <<"\n";
	cout << "Dimes: $" << dimesWorth <<"\n";
	cout << "Nickels: $" << nickelsWorth <<"\n";
	cout << "Pennies: $" << penniesWorth <<"\n";

	double totalDeposit = dollarsWorth + quartersWorth + dimesWorth + nickelsWorth + penniesWorth;

	cout << "Account Holder: " << name <<"\n";
	cout << "Total Deposit: $" << totalDeposit;
	cout << "\n";
	cout << "\n";
	cout << "\n";
	cout << "\n";

	/*You found a stash of pennies and you want 
	to turn them in for the least amount of coinage. For example if you have 131 pennies, 
	you will get 1 dollar bill, 1 quarter, 1 nickel, and 1 penny.*/

	int x;
	cout << "How many pennies do you have? ";
	cin >> x;

	cout << "amount due: \n";
	cout << "dollars: " << x = x % 100;
	cout << "quarters: " << x = x % 25;
	cout << "dimes: " << x = x % 10;
	cout << "nickels: " << x = x % 5;
	cout << "pennies: " << x = x % 1;


	return 0;




}
Did you mean to write this?
1
2
3
4
5
cout << "dollars: " << (x = x % 100);
cout << "quarters: " << (x = x % 25);
cout << "dimes: " << (x = x % 10);
cout << "nickels: " << (x = x % 5);
cout << "pennies: " << (x = x % 1);
This code doesn't really make sense, though.
I did mean to do that but I'm realizing that I actually have the math wrong on that part I'm looking for how many times those particular values go into x... so there is one problem making another but very helpful... Thank you so much for even giving a glance...
this is what the ending code looks kind of like, but I can't seem to get my calculation to go through without a error message

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
	int x;
	cout << "How many pennies do you have? ";
	cin >> x;

	double dollarAmount, quarterAmount, dimesAmount, nickelAmount, penniesAmount;

	dollarAmount = x / 100;
	x = x % 100;
	quarterAmount = x / 25;
	x = x % 25;
	dimesAmount = x / 10;
	x = x % 10;
	nickelAmount = x / 5;
	x = x % 5;
	penniesAmount = x / 1;



	cout << "amount due: \n";
	cout << "dollars: " << dollarAmount <<"\n";
	cout << "quarters: ";
	cout << "dimes: ";
	cout << "nickels: " ;
	cout << "pennies: ";
Last edited on
Topic archived. No new replies allowed.