Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Need help with a class assignment

paladianpaladian Member Posts: 2
[b]Scenario:[/b]
As you peruse various websites on the Internet, looking to create a banner for your new business, you notice that many places charge you by the letter. You want to be able to quickly count the letters on the various banners you design, so you decide to create a letter counter for yourself.

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.

[b]This is my code:[/b]

#include "stdafx.h"
#include
using namespace std;



int _tmain(int argc, _TCHAR* argv[])
{
char letter;
int count = 0;
double ppl = 0;
double finalCost = ppl * (count - 1);

cout << " Welcome to the Word Counter!
";
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;
}

Chad
Sign In or Register to comment.