C++ :: Cab Company Program / Endless Loop?

Jan 14, 2015

I'm trying to get this program to return total taxi cab fair an infinite number of times, however, when I use the while statement after for and try to run the program, it just keeps displaying the first total fair rapidly.

specifications:A cab company needs a program to calculate the cost of a cab ride.

The driver will enter the length of the trip in miles.

The miles entered must be greater than 0.

Create a function to calculate the charge. The function should receive one argument, the length of the trip, and should return the total fare for the ride.

The taxi charges a fixed charge of $2.50, plus an additional charge of $1.85 per mile.

Allow the user to calculate any number of trips.

At the end display the total of all the fares.

here is my code:

#include <iostream>
#include <iomanip>
using namespace std;
//function prototypes
double getLength ();
int main () {

[code]....

View 3 Replies


ADVERTISEMENT

C++ :: Linked List Concatenation - Endless Loop

Apr 22, 2013

Having trouble with concatenating a linked list.. When I call the display function for the concatenated list, it loops endlessly?

#include <iostream>
#include <cstdlib>
using namespace std;
#ifndef Null//Null is being defined to 0 here
#define Null 0
#endif

[Code] ....

View 5 Replies View Related

C Sharp :: Loop In A Button / Runs Endless When Pressing The Button And Not Only Once

Jun 10, 2014

I have an code that makes form window + button bet bigger when pressed each time, but it runs endless till out of screen,

code:
{
int S1 = 300;
int S2 = 0;

[Code]...

make it so it runs only each time i press the button?

View 2 Replies View Related

C++ :: Payroll Program Of A Company That Have At Least 5 Employees

Oct 1, 2014

Make a c++ program of the payroll of a company

input values :
a. Name of Employee
b. Position in the company
c. No. of hours worked
d. No. of overtime hours
e. rate per hour

formula:
basic pay = number of hours worked x rate per hour
ot pay = overtime hours x 150% of rate per hour
gross pay = basic pay + ot pay
tot deduc = tax + sss + med

tax can be computed based on the following table:
basic pay tax
10000 or less 1% of basic pay
10001-15000 2% of basic pay
15001-20000 3% of basic pay
20001-30000 4% of basic pay
30001 or more 5% of basic pay

sss = 10% of basic pay
med = 6% of basic pay

net pay= gross pay - total ded

*The payroll should have at least 5 employees in it.*

View 11 Replies View Related

C++ :: Program To Calculate Company Weekly Payroll - Calling Functions?

Jun 9, 2014

This program in not completed. I am creating a large program in order to calculate a company's weekly payroll. For now I am filling in the separate functions piece by piece before the rest of the program is completed.

Right now I am trying to use separate functions to call other functions. I need to ask the user for the file name and then open the file. I am no longer getting any compiler errors however when I run the program all it displays is "Welcome."

So it's not actually calling the NameTheFile function and the OpenTheFile function. It just says "Welcome" and then closes down. Why is it doing this?

/*Program to determine company's weekly payroll*/

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void NametheFile() {

ifstream inputFile;

[Code] ....

View 1 Replies View Related

C++ :: Program For Used Car Dealer Company To Maintain Cars Inventory And Details

Aug 25, 2014

You are required to write a program for a Used Car Dealer company. In the system you need to maintain the cars’ inventory and details. Each car in the company contains the following details:

• Car Registration Number
• Car Make or Brand
• Car Model
• Car Colour (eg. Silver, Black , Red)
• Year of manufacturing (The year the car was manufacture)
• Engine Capacity (in cc)
• Transmission (manual or automatic)
• Cost of the car (SGD)

The Car Registration Number is in the format of AAA1234 or AA1234A or A1234A which is accordance to the Malaysia car registration format. The A alphabet is in accordance to the registration number for respective in Singapore. (eg. AEW9829 or W1212Y or MCD1177). Note the A and the 1234 total count in the registration number can be less than 3 like AT9829 or BHY280. The Car Make is for the identifying the manufacturer of the car like Honda, Toyota, Proton..etc. The Car Model is to represent the Manufacturers’ respective model like Honda City, Honda Civic, Honda Accord, Toyota Vios, Toyota Camry … etc.

You are required to create menu and operations for:

1) Create a new Car account
2) Edit existing Car account details
3) Remove a car account from the system
4) Search for cars in the system (based on Car Make, Model, Year of manufacturing or Price)
5) Check total inventory in the system

View 1 Replies View Related

C/C++ :: Prevent Endless Output Of Sentences?

Nov 16, 2014

After I have compiled and executed code below, and I have made an input of a string, the while loop takes over the control and outputs an endless flow sentences. How can I make sure when an input of string is made, such a thing does not happen? In Python, one can make a type check by the use of type() command, but such a command does not exist in C, so how can I prevent an endless output in case a string input is made by the user?

(The code below is supposed to check whether the number entered by the user is divisible by 7 or not.)

#include <stdio.h>
int main() {
int a = 0;
printf("Input a number!");
while (1 < 2){
scanf("%d", &a);
if (a % 7 == 0) {

[Code] ....

View 3 Replies View Related

C :: Loop Does Not Work And Program Quits Without Displaying For Loop Function

Oct 13, 2014

We are making a program--but every time we input a value for scanf, the following for loop does not work and the program quits without displaying the for loop's function. We are not getting any errors.

View 11 Replies View Related

C/C++ :: Build A Sales Company Class?

Jul 1, 2014

Build a class named "salesCompany". Save it's name with a string and an array with records which will be filled with values from sales in different cities of the company.

Build the constructor which must get as a parameter the name of the company and a text file which will fill the array. There is an example of the text file format. Every line saves the sold quantity of a product, identified by a code, in a certain city.

CodeCityQuantity
1a63bCity11200
45ab8City2550
#include <iostream>
#include <string.h>
using namespace std;
class salesCompany {

[code].....

what should I add more and how can make it available for the user to enter as an input a text file.

View 1 Replies View Related

C :: Obtain Check Number And Then Company Information From Datafile

May 13, 2013

I have to obtain a check number from a datafile and then also get company information also from a datafile.

So my first question is about the:

Code:
char outputFilename[]= "out.list"

Is this the name of the output file I'm going to write to? And also the file has to be created before being used...is that line of code creating the file or do i have to create it in notepad?

Code:
FILE *ifp, *ofp;
char *mode = "r";
char outputFilename[] = "out.list";
ifp = fopen("in.list", mode);
if (ifp == NULL) {
fprintf(stderr, "Can't open input file in.list!

[Code] .....

View 7 Replies View Related

C :: Create List With Employees Of Company Using Binary Trees

Dec 5, 2013

My colleague and I have been given a task to create a list with the employes of a company using binary trees. Each employee/node has to contain the following information:

- Employe name
- Rank
- ID Number
- monthly Salary

We have to write a C program (using Codeblocks) which builds the company tree with the information above and afterwards lists all the employes who have a salary bigger then a number specified by the user.

So far so good. We've had a look on the examples on the internet and after finding one which looked friendly enough we started working on that one to suit our needs. Credits for the original source code to: C Program to Implement Binary Search Tree Traversal - Basic C Programs | C Programming Examples

We've reached the point where we're able to insert the required information but being able to list all the employes who's salary is bigger then the number given by the user seems to be rather difficult to achieve. I'll include the code next. We have left almost the entire pieces of the original code and we are aware that the are still things which are not required for our assignment, which only requires to enter the 4 information above and afterwards display the employes with the before mentioned condition concerning their salary.

Code:
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
typedef struct BST

[Code] .....

View 1 Replies View Related

C++ :: Calculate Area For 500 Different Measurements For Playground Company In Region

Feb 13, 2014

You are writing a program to calculate the area for 500 different measurements for a playground company in the region. The company must calculate square footage of each prospective playground, as well as the total cost to mulch each area. The cost of mulch changes frequently, so the company would like to be able to input the current cost per square foot of mulch each time they run the program. Since the quantity of data is large, the input should come from a file called “measurements.txt”. You can assume the file includes the length of each prospective playground, followed by the width. The file will be in the following format.

450300
120210
.
.
.

Ask the user the name of the file they would like to write to, as well as the current price of mulch per square foot. Output the area of each playground, along with the total price of mulch to the file that the user specifies. The playground company would like each column of output to be 20 characters in width. Each column should have an appropriate heading in the output file. You should format your output data appropriately. For example, for the input data displayed above, along with a $2.00 per square foot mulch price, the output would be:

Area Total Mulch Price
135000 $270000.00
25200 $50400.00

View 3 Replies View Related

C++ :: Painting Company - Calculate Amount Of Paint Required For Every Contract

Dec 15, 2014

You work for a painting company. Your job is to calculate the amount of paint needed for every contract assigned to the company. This time, you need to paint an outside wall. The dimensions of the wall are 5 X 7m. The window is a circle with the radius of 1m. Write a program that would calculate the following:

The amount of paint needed knowing that you need 1 gallon per 10 square meters. The amount of time to complete the job knowing that it takes 1 hour per 10 square meters to prepare the surface, 5 minute per square meter to pant it and 5 minute per square meter to clean up the area.

View 8 Replies View Related

C++ :: Functions Without Parameters - Compute And Print Total Number Of Products For Company

Mar 27, 2013

Summary: 6 companies have a product in 5 different warehouses. Each company is identified by a positive ID number and each warehouse is identified by a number (1 for the first, 2 for the second,…)

Object: the object of this assignment is to write a C++ program which asks the user to enter a company ID number, and the number of products in each of the warehouses. It then computes and prints the total number of products for that company

If the total number of product is less than 100, it prints the message “place a new order”

Input: for each company, its ID, and the number of products in each warehouse with appropriate prompt messages.
Example: Enter company ID number: 101
Enter number of products in warehouse #1:30
Enter number of products in warehouse #2:60
Enter number of products in warehouse #3:0
Enter number of products in warehouse #4:5
Enter number of products in warehouse #5:27
The total for company 101 is:122

Output: for each company, the total number of product, and the message “place a new order” if the total number of product is less than 100.

Method:
1. Define global variable, int total_prod to hold the total number of products for a company
2. define the function void compute_total() that uses a loop to read the number of the products in all warehouses for one company, computer the total number of products and store it into the global variable total_prod.
3. Define the function void new_order() that determines if a new order need to be placed as follows: if the total number of products (in the global variable total_prod) is less than 100, it prints the message “place a new order”
4. Your function main does the following in a loop:
- read a company ID number
- call function compute_total() to read the number of the product in all warehouses for that company, and to compute their sum
- print the total number of the product for that company with an appropriate message
- call the function new_order() to determine if a new order need to be placed.

View 17 Replies View Related

C++ :: Program With Do-while Loop To Restart Program And Validation

May 11, 2013

I am having problems at the end of the program with the do-while loop to restart the program and the validation.

#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>
#include <time.h>
using namespace std;

[code]....

View 3 Replies View Related

C++ :: Creating Do-While Loop In Program

Apr 28, 2014

I need starting a do-while loop in my program that runs up to 10 time that asks the user to enter up to 10 scores, which include the slope and rating for the course, and calculates the handicap for each score.

Here's what I have so far:

Code:
{
//This program calculates a golfers handicap.
#include <iostream>
#include <string>
using namespace std;

[Code] ....

View 1 Replies View Related

C :: Use A Loop To Restart A Program

Feb 21, 2015

I've just started to learn C programming. In following program I need to use a loop, so at the end, it asks the user that if wants to try other numbers or not. If yes program restarts from beginning.

Code:
/*
A program who checks three positive integers to be 3 sides of a triangle and calculates the area and shows the triangle type.
*/

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void)

[Code] .....

View 11 Replies View Related

C :: Simple Loop Program?

Feb 27, 2014

3. Write a program that reads a sequence of positive integers and prints out their sum, except that if the same number occurs several times consecutively, ignore all but the first. Assume an input of 0 marks the end of the input. For example, if the input is 3 8 5 5 4 9 1 1 1 1 8 0 then you should print 38 (i.e., ignore one of the 5's and three of the 1's).

View 5 Replies View Related

C :: Make A Program Using While Or For Loop?

Nov 20, 2014

I'm trying to write a program for a lab, I know how easy it is but cant see to crack it.

I need to make a program using while or for loop.

I must have the user type a number, for an input value an output value but then do it again several times but without it going on forever asking again and again.

View 4 Replies View Related

C++ :: How To Make A Loop So Program Never End

Aug 29, 2014

How to make a loop so program never end, it end only by typing "EXIT"

View 1 Replies View Related

C++ :: Program To Enter Limit Of A Loop

Feb 20, 2013

I need a program in c++ that will enter a limit of the loop. using nested for loop with a limit of 3 loops only.

like this !

for (){
for (){
for (){
cout
}
}
}

Sample output:
Enter a number : 3 [enter]

1 2 3
4 5 6
7 8 9

2 3 4
5 6 7
8 9 10

3 4 5
6 7 8
9 10 11

View 2 Replies View Related

C/C++ :: Infinite For Loop - Program Just Closes

Feb 10, 2015

So I learned how to make a basic for loop and I decided to try my best to make an infinite one. Every time I run it, it doesn't say anything and just closes. Visual Studio doesn't say there's anything wrong with my code.

Here's the code

#include <iostream>
#include <conio.h>
using namespace std;
int main () {
int d = 9;
for(int k = 10; k < d; k = k +1) {
cout << "For loop value = " << k << endl;
getch();
} }

View 4 Replies View Related

C/C++ :: How To Loop A Program Back To Beginning

Mar 4, 2014

I was asked by my teacher to create while loop for this, iv have completely for gotten how and all the tutorial that i have found show basic lopping.

#include <iostream>
#include <iomanip>
using namespace std;
void checkAnswers(char[], char[], int, int);
int main(int argc, const char * argv[]) {
int choice = 0;
const int num_question=20;
const int min_correct=15;
char answers[num_question] ={

[Code] ....

View 5 Replies View Related

C++ :: Decipher Program - Nested Loop

Feb 17, 2013

I'm writing a series of basic decipher programs and I have run into an issue where I get the correct answer when I start the loops at the iteration that contains the correct answer.

Code:
// generate key "words" with length of 3
for (int x = 0; x < 26; x++){
for (int y = 0; y < 26; y++){
for (int z = 0; z < 26; z++){

[Code] ....

This is the essence of the loop, I've attached the program in its entirety if necessary. Basically what happens is if I start the loops at x = 17, y = 7, z = 12, then I get the correct decipher shifts but if I start at 0,0,0 whenever it gets to that iteration (12,000 ish) the shifts are off by 2 or 3. "koq" should translate to "the" but im getting "dcz". Is this a simple bug in the or is something moving to fast for something else to keep up?

l3_ws.txt
main.cpp

View 1 Replies View Related

C :: Make A Program That Multiplies Loop Variable By 2

Nov 15, 2013

I have an exam in C programming I'm a little stuck on loops..I have to make a program that multiplies the loop variable by 2 then takes away 1... easy, that was a for loop no problem

for (x=3; x<=65; x=x*2-1)

that should print out 3 5 9 17 33 65 however, my lecturer has given the task for it to reverse, but not to display the number 17 on the way back down using an if statement...however, this time it must be a do while loop... This is what I have so far.

Code:

#include <stdio.h>
#include <stdlib.h>
int main()
{
int x = 129;
}

[code]....

View 7 Replies View Related

C :: Program To Calculate Factorial Of Numbers - For Loop

Feb 5, 2013

I have been working on a program to calculate the factorial of numbers. Part of my code is copied and modified from the FAQ about validating numbers in user input.

I have encountered a problem with the for loop that I am using near the end of my code. No matter what I do, it seems that my loop only does the multiplication of b = a*(a-1) and then prints. For example, inputting 5 will result in a print of 20, but the factorial is 120.

Code:
int main(void) {
char buf[BUFSIZ];
char *p;
long int a;
long int b;
long int i;

printf ("Enter a number to be factorialized: ");

[Code] ....

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved