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
Roger wants to give semantic meaning to the contact information, which is at the bottom of the web page. To do this he will use
Elden [556K]

Answer:

Parent

Explanation:

HTML is an acronym for hypertext markup language and it is a standard programming language which is used for designing, developing and creating web pages.

Generally, all HTML documents are divided into two (2) main parts; body and head. The head contains information such as version of HTML, title of a page, metadata, link to custom favicons and CSS etc. The body of a HTML document contains the contents or informations that a web page displays.

In this scenario, Roger wants to give semantic meaning (an element conveying informations about the type of content contained within an opening and closing tag) to a contact information placed at the bottom of a webpage. Thus, in order to do this, he should use a footer element as a parent of the contact information and as such all instance variables that have been used or declared in the footer class (superclass) would be present in its contact information (subclass object).

4 0
2 years ago
For Internet Protocol (IP) v6 traffic to travel on an IP v4 network, which two technologies are used
qaws [65]

Answer:

These technologies are: Dual Stack Routers, Tunneling, and NAT Protocol Translation.

Explanation:

Dual Stack Routers -  This is the process in which a router’s interface is attached with IPv4 and IPv6 addresses

Tunneling -Tunneling is used as a medium to help the different IP versions  communicate with the transit network.

NAT Protocol Translation -  This helps the IPv4 and IPv6 networks communicate with each other since they do not understand the IP addresses of each other since, they are different IP versions.

3 0
2 years ago
you have been tasked with configuring a digital information station in the office's lobby. guests will be able to use the statio
REY [17]

The most important security consideration for the station is code signing. With code signing, consumers may feel confident about the software they are downloading and can stop worrying about infecting their computer.

With code signing, consumers may feel confident about the software they are downloading and can stop worrying about infecting their computer or mobile device with malware. Code signing has grown in importance for software developers and distributors as more software may be downloaded from the Internet.

Malware can be easily installed on a victim's computer by an attacker who poses as a trustworthy source. As long as users only download software that is regarded as safe by their operating system, code signing ensures that these types of assaults cannot happen.

Nowadays, the Operating System looks for the digital certificate produced through code signing when software is downloaded onto a computer to ensure the security of the software being installed. The user is informed and given the option to stop or continue the installation if no digital certificate is detected.

To know more about code signing click here:

brainly.com/question/28860592

#SPJ4

3 0
8 months ago
What does the term hardware refer to?
Jobisdone [24]

Answer:

The physical components that a computer is made of

Explanation:

as u can see these components and u can repaire these components if they got damaged

6 0
3 years ago
Refer to the exhibit. An administrator is examining the message in a syslog server. What can be determined from the message? Thi
ad-work [718]

Answer:

This is a notification message for a normal but significant condition

Explanation:

Syslog represents the standard for logging message, it sends messages through UDP port 514. Familiar syslog facilities includes IP, OSPF protocols, etc. The messages from syslog are both about facility and level.

A syslog server is a means through which network devices sends messages about events into a logging server which is called syslog server. Since a syslog protocol supports so many devices, it can also be used to log a good number of events.

8 0
2 years ago
Read 2 more answers
Other questions:
  • What is the purpose of an internet protocol address (ip address)? it specifies whether a computer is using a broadband network o
    10·1 answer
  • 1.Terry turned on his computer one day to find that all of the storage on his computer was filled up. Furthermore, there were ma
    6·1 answer
  • You have to display or connect to network shares on remote computers. Which command-line utility will you use to accomplish the
    10·1 answer
  • Create a program named Reverse3 whose Main() method declares three integers named firstInt, middleInt, and lastInt. Assign the f
    9·1 answer
  • With respect to computer networks, organizations often install a dedicated telephone system called a ________ to route external
    8·1 answer
  • Jimmy has been issued a citation for littering in a city park. When Jimmy
    8·1 answer
  • I need help, who is a great phone pin lock screen cracker?
    9·1 answer
  • Here is the header for a function named computeValue:
    11·1 answer
  • Assignment 10 - 1/0 Streams and Files Create a C++ a program that will compute the average word length (average number of charac
    13·1 answer
  • 2) A ________ uses electronic memory and has no motors or moving parts. A) mechanical hard drive B) solid-state drive C) Blu-ray
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!