unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Programming > C and C++

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 06-15-2007, 12:17 PM
Neo_Reloaded Neo_Reloaded is offline
Tutorial Admin
 
Join Date: Dec 2006
Posts: 259
Default (C) Phone bill Calculator

By Chernobyl

Here is another of my coding exercises from college, this will allow the operator to input a persons name, then it will ask for each call length in minutes until the bill is more than or equal to $100. It will then display the total number of calls, the total bill cost and the average cost per call

Code:
/*
	Problem 2
	By Stephen V (Chernobyl)
	WwW.Console-World.Org
*/

#include <stdio.h>

void main()
{
	char name[15];
	short int callMins = 0, calls = 0, callNum = 1;
	float callCost = 0, bill = 0, avCost = 0;

	printf("Please enter the phone account holders name: ");
	gets(name);

	do
	{
		printf("Please enter the length (in minutes) of call %d:", callNum);
		scanf("%d", &callMins);

		if(callMins <= 5)
		{
			callCost = callMins * .15;
		}
		else
		{
			if(callMins <= 15)
			{
				callCost = (callMins - 5) * .10 + .75;
			}
			else
			{
				callCost = (callMins - 15) * .075 + 1.75;
			}
		}
		
		bill = bill + callCost;
		avCost = bill / callNum;
		calls++;
		callNum++;
	}
	while(bill <= 100);

	//Display bill information
	printf("\nTotal Calls: %d\n", calls);
	printf("Bill total: $%.3f\n", bill);
	printf("Average Call Cost: $%.3f", avCost);

	printf("\n\nPress ENTER to continue!");
	fflush(stdin);
	getchar();
}
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
calculator, phone

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 05:23 AM.