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

  Reading of coefficients

Reading of coefficients a, b, c shall be done by a function named readCoeffs(). They shall be entered as double's from the keyboard by an operator, after prompt, as follows.

  Define two derived classes of the abstract class

Define two derived classes of the abstract class ShapeBase below. Your two classes will be called RightArrow and LeftArrow. These classes will draw arrows that point right and left,

  After the user presses any key

After the user presses any key, the board will be scrambled by making a large number of random moves (for a 3x3 puzzle, 100,000 attempted random moves in random directions will result in a sufficiently scrambled board)

  Compare the running time of two versions of the insertion

implement Uniform Random Number generator and Generate 1000 Random number between 0 an 10000. Try to use insertion sort to sort them. Compare the running time of two versions of the insertion sort.

  A series of one-digit non-negative numbers

Write a program that asks the user to enter a series of one-digit non-negative numbers

  Define a function named average grade

Define a function named average grade. This function returns a double and has four double arguments, testi, test2, test3, test4. The return value should be the average, or arithmetic mean of the four arguments.

  Define a structure to store marks of a student

Define a structure to store roll no, name and marks of a student - using the structure of Q2. a), above write a 'C' program to create a file "student.dat". There must be one record for every student in the file.

  Write a program to crypt its input accordingly

Write a program to crypt its input according to a specified transformation scheme

  Use the getint and getintwithinrange methods

Use the getInt and getIntWithinRange methods to validate that each score ranges from 1 through 100 and add code that discards any extra entries at the prompt that asks if you want to enter another score to the application below.

  Perform operations on arrays

Perform operations on arrays execute tests and repetitions

  Create your own while-end repetition structure

Create your own While-End repetition structure. You decide the theme. You should provide both the pseudocode and the flowchart of your example. Be sure to provide an overview of what your repetition structure is doing. Provide a walk-through of yo..

  A constructor that constructs a rectangle2d

A constructor that constructs a Rectangle2D with specified points as coordinates.A no-argument constructor that creates the rectangle with points (0, 0), (5, 5) and (0, 5) and

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