Write two functions to be called by the main program

Assignment Help C/C++ Programming
Reference no: EM13315074

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 <iostream> 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".

Reference no: EM13315074

Questions Cloud

Find the electron speed just before electron strikes screen : In a television picture tube, electrons strike the screen after being accelerated from rest through a potential difference of 32000 V. find the electron speed just before the electron strikes the screen
How many grains of rice were placed on the 16th square : there is a legend that the inventor of chess asked fora small payment in return for the marvelous game he had developed; one grain of rice for the first square on the chess board, two for the second square, four for the third square, and so on.
How much of the $180,000 is a dividend to libby : How much of the $180,000 is a dividend to Libby?
What is the name of the anatomical plane : The physical therapist Is examining a rehab patient right knee in preparation for fitting them a knee brace. What is the name of the anatomical plane in which this flexion/extension motion occurs
Write two functions to be called by the main program : CSC250 Assignment. 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 ..
Identify the commodity of comparative advantage : State the commodity in which each country has absolute advantage and Identify the commodity of comparative advantage for each country
Compute and compare the hydraulic conductivity of formation : Compute and compare the hydraulic conductivity (m/s) of a formation with respect to the three liquids below. The formation has a permeability k = 0.1 darcy and g = 9.8 m/s2. Liquid viscosity (g/cm s) density (g/cm3)
Determine the diameter of the wire be that you fashion : You have been given 4.4584807 g of copper from which you are to fashion a wire whose resistance is 1.2941073 ohms. What will the diameter of the wire be that you fashion
Issuance of the bond : AB company issued a 10 year, 4%, $2,000,000 redeemable bond issue paying interest twice a year on December 31 and June at an effective rate of 3.6% on June 30, 2014. On September 30, 2019, AB redeemed forty percent of the bond issue at 101.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a sumo robot c program

Write a sumo robot c program for an aduino board, using 2 motors. 2 phototransistors and 2 Led sensors( sensors 2 for the front and 2 for the back ) which are going to be responsible for keping the robot in the sumo ring, making sure the robot com..

  Program which asks the user for due date of next assignment

Write a program which asks the user for due date of the next assignment (hours, minutes). Then print number of minutes between the current time and the due date in format.

  Prepare an arbitrary sinusoidal waveform

Create a program to compute the derivative of an arbitrary input function, with arbitrary duration and arbitrary limits

  Flipflaps - game based on pancake sorting

The project is to design and write a C++ 11/FLTK game program with a graphical user interface.The game is based on "pancake sorting,", which actually has some mathematical significance.

  Write c program which has parent process and child process

Write a C program that has a parent process, a child process, and a grandchild process. The parent process should print its id and the square or 5.

  Containing all the genes in the dna sequence

As described above plus an integer reference parameter, and return a dynamically-allocated array of strings containing all the genes in the DNA sequence. Each string in the array will contain a unique

  Design a class box that defines a box on a floor

Design a class box that defines a box on a floor. A box has a number and an (a,b) location where a and b are numbers between -5, and 5.

  Design in c a unix utility program gasp

Design in C a Unix utility program gasp. Command gasp [options] STRING FILE... must read listed files (FILE...) and copy each line from input to stdout if it contains STRING.

  Computers have trended to larger word

Since the beginning, computers have trended to larger word sizes, 8 to 16 to 32 and now some 64 bit computers. Explain a pro or a con in a computer with a larger word size, or comment on someone else's pro or con.

  Declare a vector

Declare a vector of these structures where the size of the vector is to be 7.

  Represent an instruction supported by simpletron

Implementation contains a Simpletron class and several supporting Instruction classes

  The function should return a value

The function should return a value of 1 when it is given a valid score to process and 0 when the received value is out side of the 0-10 range. In this case it should print a waring message on the screen

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd