My teacher gave us this assignment, I don't want to ask him, because it looks like I didn't read the chapter. But, I cannot find the answer to this one and hopefully someone could give me a hand.
This is the end part of the code :
//Ch4Lab1.cpp
//Calculates and displays the total price
//Created/revised by <your name> on <current date>
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
//declare variables
int numCds = '0';
double cdPrice = 0.0;
double totalPrice = 0.0;
Go ahead and run it. The first thing to do is put 3 in for cd number. And put 3.56ab (notice the misspelling). The answer should be 3 x 3.56 (whatever that is)
The problem to this is when you put in 3x (misspelled again) for CD number. What does it display? The solution is for the program to accept 3x and then put in 3.56 for price per cd. Thanks.
I'm really not quite sure I understand what your asking. If you enter 3x into the program as it is written now, you will jump right through the assignment of the double, and skip straight to the total price output. You want the program to be able to handle an entry of 3x for the number of cds? The problem is that the program is accepting the integer assignment and then leaving the rest sitting in the input stream. Try this: