1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nataly_w [17]
2 years ago
8

You are responsible for a rail convoy of goods consisting of several boxcars. You start the train and after a few minutes you re

alize that some boxcars are overloaded and weigh too heavily on the rails while others are dangerously light. So you decide to stop the train and spread the weight more evenly so that all the boxcars have exactly the same weight (without changing the total weight). For that you write a program which helps you in the distribution of the weight.
Your program should first read the number of cars to be weighed (integer) followed by the weights of the cars (doubles). Then your program should calculate and display how much weight to add or subtract from each car such that every car has the same weight. The total weight of all of the cars should not change. These additions and subtractions of weights should be displayed with one decimal place. You may assume that there are no more than 50 boxcars.
Example 1
In this example, there are 5 boxcars with different weights summing to 110.0. The ouput shows that we are modifying all the boxcars so that they each carry a weight of 22.0 (which makes a total of 110.0 for the entire train). So we remove 18.0 for the first boxcar, we add 10.0 for the second, we add 2.0 for the third, etc.
Input
5
40.0
12.0
20.0
5. 33.
0
Output
- 18.0
10.0
2.0
17.0
-11.0
Computers and Technology
1 answer:
maks197457 [2]2 years ago
4 0

Answer:

The program in C++ is as follows:

#include <iostream>

#include <iomanip>

using namespace std;

int main(){

   int cars;

   cin>>cars;

   double weights[cars];

   double total = 0;

   for(int i = 0; i<cars;i++){

       cin>>weights[i];

       total+=weights[i];    }

   double avg = total/cars;

   for(int i = 0; i<cars;i++){

       cout<<fixed<<setprecision(1)<<avg-weights[i]<<endl;    }

   return 0;

}

Explanation:

This declares the number of cars as integers

   int cars;

This gets input for the number of cars

   cin>>cars;

This declares the weight of the cars as an array of double datatype

   double weights[cars];

This initializes the total weights to 0

   double total = 0;

This iterates through the number of cars

   for(int i = 0; i<cars;i++){

This gets input for each weight

       cin>>weights[i];

This adds up the total weight

       total+=weights[i];    }

This calculates the average weights

   double avg = total/cars;

This iterates through the number of cars

   for(int i = 0; i<cars;i++){

This prints how much weight to be added or subtracted

       cout<<fixed<<setprecision(1)<<avg-weights[i]<<endl;    }

You might be interested in
18. Applying what formatting option to your Excel workbook will make it easier to read when printed out?
Sergeu [11.5K]
Depending on the data all answers can be used to make it easier to read. Without more info I would go with Borders (D) since they are the best way to group the data when printed, especially if the print is in color.

Alignment would be the correct answer only if the data goes out of cell boundaries. Font Color usually makes it harder to read because of bad contrast and finally changing the Font Style has a minimal effect since the default one is already pretty readable.
7 0
3 years ago
Interest assessments are always accurate. True False
Brums [2.3K]

Answer:

False

Explanation:

3 0
3 years ago
To do a good job of searching periodicals at your library, you should use A) the Library of Congress Authorities webpage. B) web
jonny [76]

Answer:

C) the online catalog.

Explanation:

An online library catalog describes the periodicals, videotapes, and books as it is the electronic bibliographic database. This evolved from the printed source, the library card catalog. Hence, this clarifies that its C. the correct option.

However, LexisNexis is the unit that gives computer-assisted research CALR and business research as well as risk management services. So through this, you can get the legal and journalistic documents.

And the stack or the book stack which is referred to as the library building block is for book storage. And the library of Congress Subject Headings is active since 1898 and holds the catalog materials which are being collected by the Library of Congress, and they do not keep track of periodicals. And the BizMiner is for financial reports.

Hence, the correct answer is the C) the online catalog.

5 0
3 years ago
Mation about which osi layers of connected cisco devices can be verified with the show cdp neighbors comm
fgiga [73]
The show CDP neighbor command operates at the Data link layer (Layer 2)

Cisco Discovery Protocol (CDP) is a proprietary Data Link Layer protocol developed by Cisco Systems. It is used to share information about other directly connected Cisco equipment, such as the operating system version and IP address.

6 0
3 years ago
Which of the following statements is not true? Group of answer choices
Nesterboy [21]

Answer:

A

Explanation:

Option A is not true because a Boolean variable type can hold one of two values only that is  (true/True or false/False).

All the other options given in the question are correct because

  1. A variable declaration refers to specifying its type and name
  2. If string variables are assigned a numeric values which is legal provided the values are enclosed in quaotes( " "), trying to carryout a mathematical operation like addition will result in string concatenation.
  3. The Variable name I_Love_to_eat_pizza is legal because it contains no special characters, doesn't start with a number and its not a reserved word in any language
4 0
3 years ago
Other questions:
  • Complete the sentence about a focusing technique.
    7·1 answer
  • If a hypothesis is strongly supported by the scientific community based on compelling experiment results, it becomes a————
    10·2 answers
  • What is considered necessary to establish OSHA
    5·1 answer
  • What is a Stereo In (&amp; Out) in audio?
    7·1 answer
  • Write a program that asks the user to enter a number of seconds. There are 60 seconds in a minute. If the number of seconds ente
    9·1 answer
  • Discuss five processes for analyzing a qualitative study
    11·2 answers
  • Does anyone know 7.1.3: Firework karel?
    5·1 answer
  • 1: define about information system in computer?
    10·1 answer
  • True or false scientists investigate and seek to explain the natural world
    14·1 answer
  • Clara works behind a computer all day. She gets a lot of headaches, and her eyes have been hurting her lately. Her doctor diagno
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!