Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

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 http://library.thinkquest.org/5512/easternchipmunk.htm

But, from http://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".

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M9894386
  • Price:- $70

Priced at Now at $70, Verified Solution

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As