answer.
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]
1 year 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]1 year 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
A bicycle sharing company is developing a multi-tier architecture to track the location of its bicycles during peak operating ho
fgiga [73]

Answer:

d use Amazon API Gateway with Amazon kinesis...

5 0
1 year ago
Which of the following is a true statement about cloud computing?
Veseljchak [2.6K]

Answer:

There are additional security risks associated with using cloud computing over local data storage.                    

Explanation:

Cloud computing: The term "cloud computing" is described as a process through which an individual tends to access and store various programs and data over the internet rather than his or her computers' "hard drive". However, the term "cloud" here refers to a specific metaphor associated with the internet.

Types:

1. Software-as-a-service or SaaS.

2. Platform-as-a-service or PaaS.

3. Infrastructure-as-a-service or IaaS.

In the question above, the very first option is correct as all other options mentioned over here are incorrect because they aren't related to cloud computing.

3 0
1 year ago
A(n) key is the set of steps used to convert an unencrypted message into an encrypted sequence of bits that represent the messag
a_sh-v [17]

Answer:

Algorithm

Explanation:

Algorithm is a set of instructions designed to perform a specific task, an independent sequence of actions to be perform to solve a problem and instruction for performing a computation.

Algorithm is A(n) key set of steps used to convert an unencrypted message into an encrypted sequence of bits that represent the message; it sometimes refers to the programs that enable the cryptographic processes.

5 0
1 year ago
Read 2 more answers
Object-oriented development could potentially reduce the time and cost of writing software because: Group of answer choices a) i
spayn [35]

Answer:

b) objects are resuable

Explanation:

In OOP there's code reuse where a method or any other body of code is defined once and called or reused severally.

3 0
2 years ago
If s=abcd is a string defined over Σ = {a,bc,d}then reverse of s is dcba.<br> Δ True<br> Δ False
Minchanka [31]

Answer:

True

Explanation:

If s=abcd is a string defined over {a,b,c,d}, it corresponds to a regular expression which can be represented using a finite automata. Then the reverse of the string essentially corresponds to another finite automata where the starting state becomes the accepting state and vice versa.Moreover all the directions of state transitions will be reversed for each of the transitions in the original automata.

With these modifications, the new finite automata will accept a string which is reverse of the original string ,namely, dcba and this string will ne part of the reverse language.

7 0
1 year ago
Other questions:
  • how do you make a circuit so 1 switch will turn on/off all the lights(3 lights) and a second switch will change the lights from
    14·2 answers
  • If a car's is malfunctioning, people in the car will become ill when driving long distances, especially if the windows are close
    6·2 answers
  • Following are groups of three​ phrases, which group states three ways to improve your​ concentration?
    13·1 answer
  • #A year is considered a leap year if it abides by the #following rules: # # - Every 4th year IS a leap year, EXCEPT... # - Every
    5·1 answer
  • Java languageThe cost to ship a package is a flat fee of 75 cents plus 25 cents per pound.1. Declare a constant named CENTS_PER_
    5·2 answers
  • Match common encryption algorithms and methods with the scenarios representing real-world business applications and requirements
    14·1 answer
  • Create a generic class Box with a type parameter that simulates drawing an item at random out of a box. This class could be used
    7·1 answer
  • The fact that the speed of a vehicle is lower than the prescribed limits shall relieve the driver from the duty to decrease spee
    11·2 answers
  • Select the correct navigational path to freeze the top row of your worksheet. Select the panes you wish to freeze. Click the tab
    15·2 answers
  • What missing condition will give you the output shown?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!