KEMBAR78
C++ Pseudo Code Week 2 | PDF | Algorithms | Computer Programming
0% found this document useful (0 votes)
354 views7 pages

C++ Pseudo Code Week 2

The document contains 8 examples of C++ code for calculating various metrics from user-provided input values. The code examples calculate things like volume of a tank, discount amounts, registration fees, costs of envelopes and pages. For each example, the input and output values are defined, and the algorithms for calculating the desired output are presented in C++ code syntax.

Uploaded by

John Riselvato
Copyright
© Public Domain
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC or read online on Scribd
0% found this document useful (0 votes)
354 views7 pages

C++ Pseudo Code Week 2

The document contains 8 examples of C++ code for calculating various metrics from user-provided input values. The code examples calculate things like volume of a tank, discount amounts, registration fees, costs of envelopes and pages. For each example, the input and output values are defined, and the algorithms for calculating the desired output are presented in C++ code syntax.

Uploaded by

John Riselvato
Copyright
© Public Domain
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC or read online on Scribd
You are on page 1/ 7

John Riselvato Week 2 2.

IPO Chart Information Input: Radius Height Process: volume Output: conditioner to add Algorithm: Scalars

C++ Instructions float r, h, volume, condToAdd;

volume = (r*r*3.1416*h); condToAdd = volume/100;

float r, h, volume, condToAdd; printf("Enter a Radius:\t"); Enter Radius scanf("%f",&r); printf("Enter a Height:\t"); Enter Height scanf("%f",&h); Calculate Volume volume = (r*r*3.1416*h); Print Volume cout << "Volume of Tank:\t" << volume << "\n"; Calculate Conditioner condToAdd = volume/100; Print Conditioner needed cout << "Conditioner to add:\t" << condToAdd << "mL\n";

John Riselvato Week 2 3. IPO Chart Information Input: Original Price Discount Rate Process: Calculate Discount Output: New Sakes Price Algorithm: Scalars Enter Original Price Enter Discount Rate Calculate Final Cost Print final Cost

C++ Instructions Float o, d, fC;

fC = o ((d/100.0)*o); fC = o ((d/100.0)*o); float o, d, fc; printf("Original Price:\t"); cin >> o; printf("Discount Percent: "); cin >> d; fc = o - ((d/100.0)*o); cout << "Final cost:\t$" << fc << "\n";

John Riselvato Week 2 4. IPO Chart Information Input: Original Price Discount Rate Process: Discount Cost Amount Saved Tax Amount Output: Discount Cost Amount Saved Final Cost Algorithm: Scalars

C++ Instructions Float original, discount, discountRate, amountSaved, taxAmount;

discountRate = (original-((discount/100.0)*original)); amountSaved = original - (original-((discount/100.0)*original)); taxAmount = (.07 * (discountRate)) + discountRate; cout << "Discount cost:\t" << discountRate << "$\n"; cout << "Amount Saved:\t" << amountSaved << "$\n"; cout << "Final Price:\t" << taxAmount << "$\n";

float original, discount, discountRate, amountSaved, taxAmount; printf("Original Price:\t"); Enter Original Price cin >> original; printf("Discount Percent: "); Enter Discount Rate cin >> discount; -Calculate Discount discountRate = (original-((discount/100.0)*original)); Print Discount cout << "Discount cost:\t" << discountRate << "$\n"; -Calculate Amount Saved amountSaved = original - (original-((discount/100.0)*original)); Print Amount Saved cout << "Amount Saved:\t" << amountSaved << "$\n"; -Include Tax taxAmount = (.07 * (discountRate)) + discountRate; Print Final Price cout << "Final Price:\t" << taxAmount << "$\n";

John Riselvato Week 2 5. IPO Chart Information Input: # of Morning Registered # of Afternoon Session Process: Total Registered Fee Output: Total Registered Total Cost Algorithm: Scalars Enter #Morning Reg Enter #Afternoon Reg Calc total Registered print total registered Calculate Fee print Fee

C++ Instructions float mornReg; float aftReg; totalReg = mornReg + aftReg; fee = totalReg * 200; float totalReg; float fee; float mornReg, aftReg, totalReg, fee; printf("Number of People for Morning Session:\t"); cin >> mornReg; printf("Number of People for Afternoon Session:\t"); cin >> aftReg; totalReg = mornReg + aftReg; cout << "Total Amount Registered:\t" << totalReg << "\n"; fee = totalReg * 200; cout << "Total Cost:\t$" << fee << "\n";

John Riselvato Week 2 6. IPO Chart Information Input: # of Morning Registered # of Afternoon Session # in both Cost/fee Process: Total Registered Fee Output: Total Registered Total Cost Algorithm: enter both session # enter morning session # enter afternoon session # enter fee Calc total reg not in both calculate fee of not in both calculate fee of both calculate total cost print total cost calculate total registered print total registered printf("Number of People in Both Sessions"); cin >> both; printf("Number of People for Morning Session:\t"); cin >> mornReg; printf("Number of People for Afternoon Session:\t"); cin >> aftReg; printf("Fee per sessoin:\t"); cin >> fee; totalRegNB = mornReg + aftReg; //Not both total cout << "Total Amount Registered:\t" << totalReg << "\n"; NBFee = totalRegNB * fee; //Not both fee feeBoth = both * (fee (fee*(.20)))*2; totalCost = NBFee + feeBoth; cout << "Total Cost:\t$" << totalCost << "\n"; totReg = both + totalRegNB; cout << Total Registered:\t << totReg << \n;

C++ Instructions float mornReg; float aftReg; float both; float fee; totalReg = mornReg + aftReg; fee = totalReg * 200; float totalReg; float fee;

John Riselvato Week 2 7. IPO Chart Information Input: Number of Envelopes Number of Pages Process: Calculate Total cost of Envelopes Calculate Total cost of Pages Output: Total Cost Algorithm: Enter envelope amount Enter page amout calculate envelope cost print envelope cost calculate page cost print page cost calculate total cost print total cost printf("Number of typed envelopes:\t"); cin >> envelope; printf("Number of typed pages:\t"); cin >> page; envelopeCost = (envelope * 0.10); cout << "Cost of typed envelopes:\t" << envelopeCost << "\n"; pageCost = (page * 0.25); cout << "Cost of typed pages:\t" << pageCost << "\n"; total = envelopeCost + pageCost; cout << "Total Cost:\t" << total << "\n";

C++ Instructions float envelopes, envelopeCost; float pages, pageCost; envelopeCost = envelopes * 0.10; pageCost = page * 0.20; float total;

John Riselvato Week 2 8. IPO Chart Information Input: Number of Envelopes Number of Pages Price of Envelopes Price of Pages Process: Calculate Total cost of Envelopes Calculate Total cost of Pages Output: Total Cost Algorithm: Enter Envelope amount Enter Page amount Cost of Envelopes Cost of Pages Calculate total cost of Envelopes Calculate total cost of Pages Calculate total cost of both print Total Cost printf("Number of typed envelopes:\t"); cin >> envelope; printf("Number of typed pages:\t"); cin >> page; printf("Cost of Envelopes:\t"); cin >> envelopeCost; printf("Cost of Pages:\t"); cin >> pageCost; totalEnvelope = (envelope * envelopeCost); cout << "Cost of typed envelopes:\t" << totalEnvelope << "\n"; totalPage = (page * pageCost); cout << "Cost of typed pages:\t" << totalPage << "\n"; total = totalEnvelope + totalPage; cout << "Total Cost:\t" << total << "\n";

C++ Instructions float envelopes, envelopeCost; float pages, pageCost;

totalEnvelope = envelopes * envelopeCost; totalPage = page * pageCost; float total;

You might also like