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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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