You are on page 1of 3

  Home Study tools

 My courses
 My books My folder Career Life 

Find solutions for your homework Search

home / study / engineering / computer science / computer science questions and answers / assignment write a program that uses a structure to st…

Question: Assignment
Write a program that uses a structure to store tra… Post a question
Answers from our experts for your tough
homework questions

Assignment Enter question


Write a program that uses a structure to store traffic counts
for three of the area's trans-bay bridges for a
three month
period.
For each of three months, track the following:
Continue to post
Total traffic across the Golden Gate bridge
Total traffic across the Bay Bridge 10 questions remaining
Total traffic across the San Mateo bridge

The program should have an array of three structures to hold


traffic information for the three months. The
program should prompt
the user to enter data for each month, for each bridge. You can use
any numbers
you wish (some real numbers are available on this site
(Links to an external site.)Links to an external site.). My Textbook Solutions
Once all data is entered, the program should calculate and
output the average monthly traffic for each of
the three bridges,
and the largest traffic count of any bridge in any one month. Print
all values with two
digits past the decimal point in fixed-point
notation.
The program must use a structure ('struct') to store the data to
receive credit, and no "hard coded"
programs (such as those that
print a fixed output or use fixed inputs) will be accepted.
Example Output: Introductio... Digital... Financial &...

The program should prompt for each of the 3 months for each
bridge, for example: 1st Edition 5th Edition 16th Edition
Enter month 1 traffic across the Golden Gate Bridge:
View all solutions
Enter month 1 traffic across the Bay Bridge:

Enter month 1 traffic across the San Mateo Bridge:

Enter month 2 traffic across the Golden Gate Bridge:

...

Then, output each of the averages and the highest single traffic
count.
In C++ Please. Thank you!

Expert Answer

Debjit answered this


Was this answer helpful? 1 0
2,550 answers

Source Code in C++:

#include <iostream>

using namespace std;

struct month //structure to store traffic across 3 bridges for


one given month

double goldenGate,bay,sanMateo;

};

int main()

month months[3]; //creating an array of 3 months

int i;
for(i=0;i<3;i++) //taking input for 3 months

cout << "Enter month " << i+1 << " traffic across
the Golden Gate bridge: "; //input prompt

cin >> months[i].goldenGate; //input

cout << "Enter month " << i+1 << " traffic across
the Bay bridge: "; //input prompt
cin >> months[i].bay; //input

cout << "Enter month " << i+1 << " traffic across
the San Mateo bridge: "; //input prompt

cin >> months[i].sanMateo; //input

double
goldenGate=0,bay=0,sanMateo=0,max=months[0].goldenGate;

for(i=0;i<3;i++) //calculating average and max

goldenGate+=months[i].goldenGate;

bay+=months[i].bay;

sanMateo+=months[i].sanMateo;

if(months[i].goldenGate>max)

max=months[i].goldenGate;

if(months[i].bay>max)

max=months[i].bay;

if(months[i].sanMateo>max)

max=months[i].sanMateo;

//output

printf("Average traffic across Golden Gate bridge:


%.2lf\n",goldenGate/3);

printf("Average traffic across Bay bridge: %.2lf\n",bay/3);

printf("Average traffic across San Mateo bridge:


%.2lf\n",sanMateo/3);

printf("Highest traffic across all bridges: %.2lf\n",max);

return 0;

Output:


Comment

Practice with similar questions

Q: C++ Problem
Write a c++ program that uses a structure to store
traffic counts for three of the area's bridges for a
three month
period.
For each of three months, track the
following:
Total traffic across the Brooklyn Bridge
Total traffic
across the Queensboro Bridge
Total traffic across the George Washington
bridge
The program should have an array
of three structures to
hold...

A: See answer

Q: Assignment Write a program that uses a structure to store traffic counts for three of the area's trans-bay bridges for a
three month period. For each of three months, track the following: • Total traffic across the Golden Gate bridge •
Total traffic across the Bay Bridge • Total traffic across the San Mateo bridge The program should have an array of
three structures to hold traffic...

A: See answer

Questions viewed by other students

Q: C++ Problem
Write a c++ program that uses a structure to store
traffic counts for three of the area's bridges for a
three month
period.
For each of three months, track the
following:
Total traffic across the Brooklyn Bridge
Total traffic
across the Queensboro Bridge
Total traffic across the George Washington
bridge
The program should have an array
of three structures to
hold...

A: See answer
COMPANY LEGAL & POLICIES CHEGG PRODUCTS AND SERVICES CHEGG NETWORK CUSTOMER SERVICE

About Chegg Advertising Choices Cheap Textbooks Chegg Math Solver EasyBib Customer Service
Chegg For Good Cookie Notice Chegg Coupon Mobile Apps Internships.com Give Us Feedback
College Marketing General Policies Chegg Play Sell Textbooks Thinkful Manage Subscription
Corporate Development Intellectual Property Rights Chegg Study Help Solutions Manual
Investor Relations Terms of Use College Textbooks Study 101
Jobs Global Privacy Policy eTextbooks Textbook Rental
Join Our Affiliate Program DO NOT SELL MY INFO Flashcards Used Textbooks
Media Center Honor Code Learn Digital Access Codes
Site Map Honor Shield Uversity Chegg Life
Chegg Writing

© 2003-2022 Chegg Inc. All rights reserved.

You might also like