Csc250 assignment write two functions to be called by the


Using the handout program about Student as a guide, write a program that would have a user-defined type - a struct - it could be called Vehicles, and use variables of this type to holddata about some trucks. It is to have three member variables: one for size of gas tank, one formiles per 2allon. and one for number of tires (the first two doubles and the last an integer). In the main program, define three variables of type Vehicles. Call one of the variables pickup,another one Mack, and another one bigrig. In the main program, write statements that can read in from the keyboard (for now) these numbers: for the pickup: 18.0 gas tank size, 20 miles per gal., and 4 tires. For the Mack, 25.0 for the gas tank size. 17.0 miles per gal., and 6 tires. For the bigrig. 70.0 for gas tank size, 12.5 miles per gal., and 18 tires. (This is a pedestrian way to get the data in and involves lots of typing, but for now it simplifies the program while we are concentrating on the struct aspect. It also reinforces how we refer to each of those individual variables.) Write two functions to be called by the main program. One function is to calculate, in general, a truck's range, that is, the distance the truck can go on one tank of gas (we should probably say fuel. since the bigrig might use diesel fuel; we'll use "gas" and "fuel" interchangeably). The other function is to calculate the excise tax, if the formula is based just on the number of tires, by tax = $86.50 (S54.25)(number of tires). Be careful to not mode-mix. As usual make the functions ``all-purpose'', so they can be called for any one of the trucks. The functions are not to print anything out. Instead they send back the results to the main program, which prints the output. Use the handout program as a guide for how to pass information to the functions.

When your program runs and is de-bugged (check the answers by hand), copy the listing of your program and save it in WordPad (under All Programs, Accessories on the side menu). Send the WordPad file through Blackboard (not by regular e-mail as an attachment). In Blackboard, you find the place to submit your Wordpad file under Assignments (on the left menu). Scroll down until you see a thread there that says "Click to submit your WordPad file" or something like that.

Generated by CamScanner from intsig.com

// This file is called C5C2505tructChipmunksC.cpp // Program to demonstrate structures

#include using namespace std;

/* Each chipmunk's length, weight, and number of teeth are measured and entered from the keyboard. Then the food allotment is calculated based on weight. Each chipmunk will get two food pellets for every 15 grams of body weight. '/

struct Chipmunk

double lengthcm; double weightg; int howmanyteeth;
} ;

void userinputsdata(Chipmunk& whichchippie); // this function goes with main. It is not part of struct int main()

Chipmunk fred,gloria; double pellets;

userinputsdata(fred);

pellets = 2.0*fred.weightg/15.0;

cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(1);

cout«"Fred gets "«pellets«" pellets since he weighs "«fred.weightg

«" grams. \n"; userinputsdata(gloria); pellets = 2.0*gloria.weightg/15.0;

cout«"Gloria gets "«pellets«" pellets since she weighs "

«gloria.weightg «" grams. \n";

return 0;

void userinputsdata(Chipmunk& whichchippie)

{

cout«"Please enter the weight of this chipmunk in grams. Use a decimal point. cin»whichchippie.weightg;

cout«endl«"Please enter its length, excluding tail, in cm. Use a decimal point. "; cin»whichchippie.lengthcm;

cout«endl«"How many teeth does this chipmunk have? Do not use a decimal point. " cin>>whichchippie.howmanyteeth;

cout«endl«"Thank you.\n";

/'

The Eastern Chipmunk's length from head to toes is 5-7 in; tail, 3-4 in. The Eastern Chipmunk's weight is 2-5 oz.

The Eastern Chipmunk has two more front teeth than other chipmunks. - from https://library.thinkquest.org/5512/easternchipmunk.htm

But, from https://en.wikipedia.org/wiki/Eastern_chipmunk

They have 2 fewer teeth than other chipmunks and have 4 toes each in the front legs but five in the back legs.[5]

And Eastern can weigh as much as 125 grams (4.4 oz.)

From previous searches, I found "20 teeth".

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Csc250 assignment write two functions to be called by the
Reference No:- TGS0653754

Now Priced at $70 (50% Discount)

Recommended (92%)

Rated (4.4/5)