Help with user input

Help with user input

Page 1 of 1

3 Replies - 1261 Views - Last Post: 26 June 2006 - 04:50 PM Rate Topic: -----

#1 Manny  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 30-May 06

Help with user input

Posted 26 June 2006 - 04:17 PM

HI All,

This program is to allow me to print a bill for my customers. My goal is
to allow as many bills to be printed as I visit the job site. this is from my CS - class help!!




/*	Program:	program# 3
	Progrmmer:	Manuel Alminha
	Dade:		6 / 06 / 2006
	Class:		CS - 161	*/


/*	This Program Will */



#include <iostream>
#include <string>
#include <ctype.h>


using namespace std;


int main ()
{



	string firstName;
	string lastName;
	char ch;
	char serviceplan;
	int code = ( 'A', 'a', 'B', 'b', 'C', 'c' );
	char Ans = ( 'Y', 'y', 'N', 'n');
	float total_cost;
	float totalbill;
	float sq_ft;
	int ID;

	float total_ccost = totalbill + totalbill;	


	cout.setf ( ios :: fixed,ios :: floatfield );
	cout.setf ( ios :: showpoint );
	cout.precision (2);


	cout << endl << endl << endl;
	cout << " \tWelcome To \" Pest Control With a hart \" Animated bill paying service. Are Company \n";
	cout << " \tHas a Carpenter Ant Removal Service. That Charges a Base Rate Of 0.50 Cents, Per \n";
	cout << " \tSquare foot. Additionally we offer two basic Plans, Are Large House Plan Offers a \n";
	cout << " \tsix month guarantee with a Maximum cost of $ 500.00, And are small house plan \n";
	cout << " \tthat has a minimum charge of $ 50.00. \n";
	cout << endl << endl << endl;


	cout << " \tPlease Enter Your First Name: ";
	cin >> firstName;
	cout << endl << endl;
	cout << " \tPlease Enter Your Last Name: ";
	cin >> lastName;
	cout << endl << endl << endl;


	cout << " \tHello: " << firstName << " " << lastName << ", " << endl;
	cout << endl << endl << endl; 


	do
	{
		cout << " \tPlease Enter Your Street Address Like \" 2323 \". \n ";
		cout << endl << endl;
		cout << " \tYour Street Address Must Not Contain More Than 4 Digits: ";
		cin >> ID;
	}
	while ( ID > 9999 || ID < 0 );


	cout << endl << endl;
	cout << " \tPlease Enter Total Square Footage Of Your Home: ";
	cin >> sq_ft;


	cout << endl << endl;
	cout << " \tPlease Select The Service Plan That You Would Like. \n";
	cout << endl;
	cout << " \tEnter \" L \" for the Large house, and \" S \" for the Small house plan. \n";
	cout << endl;
	cout << " \tPlease Enter Your Service Plan Option Here: ";
	cin >> serviceplan;


	cout << endl << endl << endl << endl;
	cout << " \tWelcome To The Loving Pest Control With a Hart, Animated Bill Paying Service. \n";
	cout << " \tWe Whould Like To Offer You an Additional Guarantee Plan. \n";
	cout << endl << endl << endl;
	cout << " \tPlease Read Over Our Guarantees And Chose Your Plan. \n";
	cout << endl << endl << endl;
	cout << " \tPlan: \" A \" Our Basic Plan For A Large Home Costs $500.00 and Comes With a Six Month Guarantee. \n";
	cout << endl << endl;
	cout << " \tPlan: \" B \" Will cost 0.20 Cents Per sq_ft. for our 3 Year Guarantee. That Comes \n";
	cout << " \tWith Maintenance Every 3 Months \n";
	cout << endl << endl;
	cout << " \tPlan: \" C \" Is Are 5 Year Guarantee, That Comes With Maintenance Every 3 Months \n";
	cout << " \tAnd Will Cost An Additional 0.40 Cents Per sq.ft. \n";
	cout << endl << endl;
	cout << " \tYour Guarantee Plan Codes Are: \" A \", \" B \" OR \" C \". \n";
	cout << endl << endl << endl;


	if ( serviceplan == 'L' || 'l' )
	{
		cout << " \tThis is An Animated Bill Paying Service. Your Service plan comes with our,\n";
		cout << " \t6 month Guarantee. That will cost $ 500.00.\n";
		cout << endl << endl;
		cout << " \tWould You Like To Add An Additional Guarantee \n";
		cout << " \tTo Your Service Plan. Y/N: ";
		cin >> Ans;
		cout << endl << endl;

		if ( Ans == 'Y' || 'y' )
		{
			cout << endl;
			cout << " \tPlease Enter Your Guarantee Code Here: ";
			cin >> code;
			cout << " \tThank You: " << firstName << " " << lastName << ", " << endl;
			cout << endl;
			cout << " \tThe Total Square Footage Of Your Home Is: " << sq_ft << endl;
			cout << endl;
			cout << " \tYour Customer ID Number Is: " << ID << endl;
			cout << endl;
			cout << " \tThe Total Cost For Your Home Is : $ " << totalbill << endl;

			if ( sq_ft > 1000 )
				totalbill = sq_ft - 1000 * 0.50 + 500.00;
			else if ( sq_ft <= 1000 )
				totalbill = 500.00;
		}
		else 
		{
			cout << endl << endl;
			cout << " \tThank You: " << firstName << " " << lastName << ", " << endl;
			cout << endl;
			cout << " \tFor Using our Animated Bill Paying Service. \n";
			cout << endl;
			cout << " \tYour Customer ID Number IS: " << ID << endl;
			cout << endl;
			cout << " \tThe Total Square Footage Of Your Home Is: " << sq_ft << endl;
			cout << endl;
			cout << " \tYour Total Cost For Your Home Is: $ " << totalbill << endl;
			cout << endl;
			cout << " \tHave you Entered all of the Guarantee opctions that you may \n";
			cout << " \twhant. Y/N: ";
			cin >> Ans;
			cout << endl << endl;

			if ( Ans == 'Y' || 'y' )
			{
				cout << endl << endl;
				cout << " \tThank You: " << firstName << " " << lastName << ", " << endl;
				cout << endl;
				cout << " \tFor Using our Animated Bill Paying Service. \n";
				cout << endl;
				cout << " \tYour Customer ID Number IS: " << ID << endl;
				cout << endl;
				cout << " \tThe Total Square Footage Of Your Home Is: " << sq_ft << endl;
				cout << endl;
				cout << " \tYour Total Cost For Your Home Is: $ " << totalbill << endl;
				cout << endl;
			}

		}



	}
	if ( code == 'A', 'a', 'B', 'b', 'C', 'c' )
	{

		if ( code == 'A' || 'a' )
		{
			if ( sq_ft > 1000 )
				totalbill = (sq_ft - 1000) * 0.50 + 500.00;
			else if ( sq_ft <= 1000 )
				totalbill = 500.00;
		}
		else if ( code == 'B' || 'b' )
		{
			cout << " \tYou Have Selected Are Guarantee Plan: \" B \", Is This Correct Y/N: ";
			cin >> Ans;
			cout << endl << endl;
		}
		else if ( Ans == 'Y' || 'y' )
		{
			cout << " \tThank You: " << firstName << " " << lastName << " " << " Your Account Number Is: " << ID << endl;
			cout << " \tThe Total Square footage For Your Home Is: " << sq_ft << endl;
			cout << " \tAnd You Have Selected Are Service Plan: " << code << endl;
			cin >> Ans;
			cout << endl << endl;
		}
		else if ( code == 'C' || 'c' )
		{
			cout << " \tYou Have Selected Are Guarantee Plan: \" C \", Is This Correct Y/N: ";
			cin >> Ans;	
			cout << endl << endl;
		}
		else if ( Ans == 'Y' || 'y' )
		{
			cout << " \tThank You: " << firstName << " " << lastName << " " << " Your Account Number Is: " << ID << endl;
			cout << " \tThe Total Square footage For Your Home Is: " << sq_ft << endl;
			cout << " \tAnd You Have Selected Are Service Plan: " << code << endl;
			cout << " \tAre We Done Y/N: ";
			cin >> Ans;
			cout << endl << endl;
		}
		if ( code > 'A' || 'a' || 'B' || 'b' || 'C' || 'c' ) 
		{
			cout << " \tYou Have Entered An Invalid Response Please Try Again: ";
			cin >> Ans;
			cout << endl << endl;

		}		



	} // End while




	return 0; 


}


Is This A Good Question/Topic? 0
  • +

Replies To: Help with user input

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Help with user input

Posted 26 June 2006 - 04:28 PM

Can you specify the problem?
Was This Post Helpful? 0
  • +
  • -

#3 Manny  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 30-May 06

Re: Help with user input

Posted 26 June 2006 - 04:44 PM

When I compile the program and I specify additional grantee. It kicks me out and it doesn’t give me the totalbill.

Thank you,
Was This Post Helpful? 0
  • +
  • -

#4 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: Help with user input

Posted 26 June 2006 - 04:50 PM

It displays it for me..except it's zero becasue you are calculating the total after you display it.

Perhaps you could post exactly what inputs you are entering at each prompt, what outputs you receive, and what you feel is missing. that way, we can track the problem.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1