Greetings, this is my first time posting here, I've been a long time lurker. I have a lab assignment which is:
Write an application where you ask the user to input the price per letter (PPL), and then ask the user to input the sentence they want printed. The application should then calculate the number of letters and give the user the total cost in the following manner:
You have 40 letters at $3.45 per letter, and your total is $138.00.
Your application should only use "FOR" loops. Do not use any String or Array functions.
This is the code I have generated so far, it builds successfully but does not work correctly and I can't figuru out why? Any help would be greatly appreciated. Thanks for any help or suggestions!
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char letter;
int count = 0;
double ppl = 0;
double finalCost = ppl * (count - 1);
cout << "\tWelcome to My Price Per Letter Calculator!\n";
cout << " What is your next character? Type '*' to end : ";
cin >> letter;
for ( ; letter != '*'; ++count);
{
cout << " What is your next character? Type '*' to end : ";
cin >> letter;
}
cout << " What is the price per letter to pay? ";
cin >> ppl;
cout << " You have "<< (count - 1) << " letters at $"<< ppl <<" per letter, and your total cost is $" << finalCost << ".";
system("pause");
return 0;
}