C++ :: Write Program That Uses Function To Compute The Cost?

Nov 1, 2013

Write a program that uses a function to compute the cost of a pizza with given diameter and the number of toppings. Constant will be the cost per toppings and cost per square inch. It will contain a reputable structure as well.

diameter=17
number of toppings=3

//complier directives
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>

[Code].....

View 6 Replies


ADVERTISEMENT

C/C++ :: Program To Compute Students Grades From File And Write Them To File?

Aug 31, 2014

We have to write a program that reads an input file containing data in the form:

Martha J, 80, 90, 90, 100, 89, 99, 85
Anna Smith, 65, 72, 77, 68, 62, 70, 65
Bill Gates, 60, 54, 89, 62, 65, 60, 50
...etc...

and then use that information to determine their letter grade and write that information to a .txt file. I have been able to successfully pass that information to a function to determine their letter grade and have been able to successfully compute their letter grade. However, I can get this information to successfully post within the *computeGrade () function. Yet, I don't know how to pass this information back to the main() on a student by student basis so that I can open a new .txt file and write just their name and letter grade to it.

Another issue I'm having is when it comes to computing the averages of the class. Each score is either a quiz (there are 4), a midterm (there are 2) or a final (there is 1). I'm a little stuck on how to pass say all of the quiz 1 grades as one entity to the function averagesminmax(). Is there a way to compile each of the grades for a specific quiz or midterm as one array and pass that to the function to then do the computation. Also we need the min and max so again from compiling the grades of a particular quiz or exam together as one.

Here's the code that I have so far.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
const char *computeGrade();
int averagesminmax();
int main() {
char fName[20];
char lName[20];

[code]....

Do I need to re-read the input file and assign them to different variables?

Here's a sample of the output so far:

Enter input .txt file name
Graded
Thui Bhu, 91, A
Ariana B. Smith, 96, A
Emily Gonzales, 83, B
Jennifer L, 89, B
Maria Jones, 67, D
Bill Gates, 55, F
Escobar Morris, 78, C
Anne Latner, 88, B
Program ended with exit code: 0

Also in my output file, the only thing that it prints will be the first name of whatever the last student in the input file list is.

View 2 Replies View Related

C :: Create A Program That Will Calculate A Shipping Cost?

Feb 16, 2015

So im trying to create a program that will calculate a shipping cost. I'm stuck on trying to calculate the actual milage and cost. Example being 1400 miles for a 2lb package would be $2 for every 500miles. so it would cost $6. But Im having trouble getting the program to round up the 1400 to 1500 so it charges the correct amount.

I know there would have to be a way to do this without programming all the conditions.

Also the course has not reached loops yet.

Code:

// This program will calculate the shipping charges.// The shipping rates are based on per 500 miles shipped.
// They are not pro-rated, i.e., 600 miles is the same rate as 900 miles or 1000 miles.
#include <stdio.h>
#include <stdlib.h>

[Code]......

View 1 Replies View Related

C :: Flowchart - Program To Compute Average Of N Numbers

Feb 20, 2015

How can you draw a flow chart that will be used to write a program to compute Average of n numbers?

View 1 Replies View Related

C :: Program Doesn't Properly Compute Simple Polynomial

Feb 7, 2014

The program will ask for the user to enter a value for x, then compute the following polynomial: 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6.However, when I double check it with my calculator I get a wrong answer for random values of x. To simplify my problem I'm using only integers.

Code:

#include <stdio.h>
int main(void)
{
int x, polynomial;
}

[code]...

View 5 Replies View Related

C++ :: Program To Compute And Print A Billing Statement For Each Patient

Oct 17, 2013

Community Hospital needs a program to compute and print a billing statement for each patient. Charges for each day are as follows:

a. room charges: private (P) room = $125.00; semi-private (S) room = $95.00; or ward (W) = $75.00
b. telephone charge = $1.75
c. television charge = $3.50

Write a program to get data from the keyboard, compute the patient’s bill, and print an appropriate statement. Typical input (nut yours do not have to be identical to this) is the following:

How many days was the room occupied? 5
What type of room? P
Telephone used during the stay? N
Television used during the stay? Y

Keep in mind that the user needs to know that the input can be any integer number of days for the length of stay, either (P, S, or W) for the room type, and either (Y or N) for both telephone and television options.

A statement (which yours MUST be identical to) for the data given follows:

Community Hospital Patient Billing Statement

Number of days in hospital: 5
Type of room: Private
Room charge:$ 625.00
Telephone charge:$ 0.00
Television charge:$ 17.50

TOTAL DUE = $642.50

View 3 Replies View Related

C++ :: Program That Compute Final Average Grades Of Class

Jan 28, 2013

An instructor needs you to write a program that will compute the final average grades in her class. There are 5 students in the class. Each student must take 2 exams and 4 quizzes as part of their final grade. The weight of each toward the final grade is as follows:

Exam 1 – 30%
Exam 2 – 30% Quiz 1 – 10%
Quiz 2 – 10%
Quiz 3 – 10%
Quiz 4 – 10%

You must use arrays to store each students 3 digit ID number, exam scores and quiz scores. A multi-dimensional array is mandatory. Request from the user the information needed then output all of the information as well as the final average grade for each student.

View 1 Replies View Related

C :: Compute Permutations Of Any String Entered - Function Will Not Return A Value

Jun 11, 2013

This is my program, for now it is intended to compute permutations of any string entered, but the function ox will not return the final x value. ox is the function that actually computes the permutations so the return of the x value is critical.

Code:
#include<stdio.h>
#include<string.h>
int ox(int x);
int main() {
int x;
char input[10];

[Code] .....

View 2 Replies View Related

C++ :: Program To Compute And Display Charges For Patient Hospital Stay

Dec 6, 2013

Write a program that computes and displays the charges for a patient's hospital stay. First, the program should ask if the patient was admitted as an in-patient or an out-patient. If the patient was an in-patient the following data should be entered:

-Number of Days spent in a Hospital
-The daily rate
-Charges for the hospital services(lab test, etc)
-Hospital medication charges

If the the patient was an out-patient the following data should be entered:

-Charges for Hospital services(lab test, etc)
-Hospital medication charges

The program should use two functions to calculate the total charges. One of the functions should accept arguments for the in patient data, while the other function accepts arguments for out-patient data. Both functions should return the total charges.

I dont know why but the result always gives me 0??? This is what I have.

#include<iostream>
using namespace std;
double in_patient(int Numdays, double dailyRate, double Charge_hospServices, double HospMed_Charge);
double out_patient(double Outcharge_Service, double OuthospMed_Charge);
int main() {

double dailyRate, Charge_hospServices,HospMed_Charge,Outcharge_Service,OuthospMed_Charge;

[Code] .....

View 4 Replies View Related

C/C++ :: Program To Compute Length Of String Entered By User By Class

Sep 30, 2014

I want this program by using only iostream.h & conio.h

View 4 Replies View Related

C++ :: User Defined Program - Compute Price Per Square Inch Of Cake Using Overloading

Nov 21, 2014

Create a user-defined program that will compute the price per square inch of a cake using an “overloading”. The cake could be a circle or a square type. In the main function, ask for the price of a circle cake and its diameter, while for the square cake, ask for the price, its length and width. The process must be done inside the different function of each cake. (Note: two sub function for the computation of a circle and a rectangle)

Note that when I made this program something weird happen. After inserting the name, all things follow.

<code>
#include "stdafx.h"
#include <iostream>
using namespace std;
double areaRectangle(int l, int w);
double radiusCircle(int r);

[Cpde] .....

View 4 Replies View Related

C++ :: Memory Cost On The Loop Of Menus?

Jun 26, 2014

I have a question on the wasting of the memory on the use of menus. What is the task: I have mainMenu, subMenu1, subMenu2, subMenu3, ... Entry from mainMenu, and chose 1(or 2, 3,..) to subMenu1. If tasks done, go back to the mainMenu.

The Codes:

void mainMenu(){
//input 1-3 by user
switch(choice) //choice is the input

[Code].....

My problem is: the call for mainMenu() in subMenus looks like a recursion, which means the memory would be reallocated again for the called maniMenu. Is that right?

If so, times of the memory space for mainMenu function are required if going back to mainMenu several times from subMenus. But what i wanna just a choice and I dont want to wast the memory.

View 4 Replies View Related

C/C++ :: Declare And Initialize A Pointer To Variable Int Cost

Mar 2, 2014

this question would their be a different process if they asked "declare and initialize a pointer to the variable int cost[N][N]" Here's what I have so far

[#include<stdio.h>
int main() {
int a; // Step 1
int *ptr; // Step 2
a = cost; // Step 3
ptr = &a; // Step 4
return(0);

[Code] .....

View 5 Replies View Related

C/C++ :: Calculate Cost From Wholesale To Final With Percentage Markup

Apr 15, 2014

Program calculates cost from wholesale to final cost with percentage markup!

#include <iostream>
using namespace std;
int calculate_retial(int,int);
int main () {
int wholesale;
int markup;
int cost;

[Code] ....

View 5 Replies View Related

C/C++ :: Calculate Total Cost Given The Tax Values - Getting C2784 Error

Sep 3, 2014

// Purpose: calculate total cost given the tax values

#include <iostream>
#incluse <string>
using namespace std;
int main() {
double purchasePrice, stateTaxAmt, countyTaxAmt, totalCost;
//Display purchase price

[Code] ....

View 2 Replies View Related

C++ :: Equation That Determines The Lowest Possible Cost For Laying Power Line

Apr 9, 2013

I need an equation that determines the lowest possible cost for laying power line.

The variables are as follows:

1. The width of a river
2. The distance a factory is downstream from a station on the other side of the river.
3. The cost for laying line underwater.
4. The cost for laying line on land.

All these variables will be user input each use of program.

View 4 Replies View Related

C++ ::  Minimum Cost Path Visiting Half The Cells In A Grid?

Mar 11, 2013

I am trying solve this a problem: [URL] .....

In short:
1. Input is an N x N grid with a non-negative integer in each cell.
2. We can move from one cell to any of its adjacent cell in all four directions.
3. The 'cost' needed to move from one cell to another is the positive difference of their values.
4. We have to find the minimum cost such that we can visit atleast half of the cells with that cost;

I am not being able to think of any solution that runs in time O(N2) or better (N2 because of the size of N, any algorithm worse than it will not run within the time limit) for this problem.

So I need a hint on how to solve this problem optimally.

View 2 Replies View Related

C :: Calculate Cost For Production Of Open Top Cylinders - User Defined Functions

Feb 20, 2013

I have this program I wrote to calculate cost for the production of open top cylinders and how to translate it into user defined functions. Here are the user defined functions I need to use instruct() get_area() comp_area() and print_area_cost() so the program will be in 4 parts.

Code:
#include <stdio.h>
int main()
{double radius,height,cost,single,all;
float surface_area;
int count;
double pi=3.14159265;
printf("Enter the radius of the base in cm^2:

[Code] ......

View 2 Replies View Related

C++ :: Word Counter - Calculate Number Of Letters And Give Total Cost

Nov 4, 2013

I am currently working on an assignment.

#include <iostream>
using namespace std;

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

[Code] ....

I am trying to create a word counter program that asks for the price per letter and then asks for the sentence they are writing. The app should then calculate the number of letters and give the total cost similar to:

You have 40 letters at $3.45 per letter, and your total is $138.00.

Everything compiles fine but when I run it the inputs don't work and it outputs:

You have -1 per letter, and your total cost is $-0.

View 2 Replies View Related

C/C++ :: Parking Garage Cost Calculator Based On Type Of Vehicle And Time

Nov 3, 2014

There are a few functions for this code and I am not very good with functions yet(we just learned about them last week).

//This program will calculate the cost of using a parking garage
//based on the type of vehicle and the time of parking.
#include<iostream>
#include<stdio.h>
#include<cmath>
#include<string>
using namespace std;
//define rates

[Code] ...

Error List:

Error1error C2100: illegal indirectionc:userscodydesktopgaragecodegaragecodesource.cpp971GarageCode
Error2error C2100: illegal indirectionc:userscodydesktopgaragecodegaragecodesource.cpp1051GarageCode
Error3error C2561: 'main' : function must return a valuec:userscodydesktopgaragecodegaragecodesource.cpp1161GarageCode

[Code] ....

View 2 Replies View Related

Visual C++ :: Calculate Total Of Monthly Costs Of Expenses And Show Annual Cost

Oct 5, 2012

The point of this is to calculate the total of the monthly costs of these 6 expenses and then to show the annual cost. However, there's just a couple of things that's giving me problems and it's the calcMonCost in my code. The error says that it is more than one instance of overload function and also that an unresolved external symbol. Everything else is fine. What does this mean?

Code:
#include <iostream>
#include <iomanip>
using namespace std;
void calcMonCost (double, double, double, double, double, double &);
void calcAnnCost (double, double, double, double, double, double &);
void getData(double &lnPymnt, double &insure, double &gas, double &oil, double &tires, double &maint);

[Code] .....

View 1 Replies View Related

C :: How To Get Program To Write Itself

Aug 27, 2013

For instance Code: int counter;
counter =0;
FILE *pfile;
pfile= fopen("g:myprog.txt" "w");
while (counter >100)
{ fprintf (case counter{something})}; how do I do this?

View 11 Replies View Related

C :: Write A Program That Would Open A PDF?

May 10, 2013

I have a batch of .pdf files (~1000) with names 001.pdf 002.pdf ...etc. Still pretty new to C, but would it be possible to write a program that would open a PDF, prompt a new name from user, and when entered, close the .pdf and open the next one in the list?

View 14 Replies View Related

C++ :: How To Write A Bootable Program

Apr 21, 2013

I want to write a bootable c/c++ Hello World. How can i do that?

View 2 Replies View Related

C++ :: Write A Program That Has 3 Subcategories?

Jul 14, 2013

So I am trying to write a program that has 3 subcategories under the category section. the subcategories are donuts, drinks and chips

struct Inv
{
double sku;
char category[SIZE];

[Code].....

I have to make the subsections here so the user can choose the category.

View 3 Replies View Related

C++ :: Compute The Value Of A Polynomial

Mar 27, 2014

This program is supposed to find the value of a polynomial

with x being the number of terms

a[x] being the coefficients

b[x] being the exponents in each term

j being the variable

for example if

x=4

a[x]=1,2,1,5

b[x]=3,2,1,0

j=2

then the polynomial is (j*j*j)+2(j*j)+j+5

the value will be 23

however the value computed is wrong in the code below

#include <stdio.h>
#include <math.h>
int main()

[Code].....

View 4 Replies View Related







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