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
Rasek [7]
2 years ago
7

Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout << fixed

<< setprecision(2); once before all other cout statements. (1) Prompt the user to enter five numbers, being five people's weights. Store the numbers in a vector of doubles. Output the vector's numbers on one line, each number followed by one space. (2 pts)
Computers and Technology
1 answer:
Fofino [41]2 years ago
5 0

Answer:

In C++:

#include <iomanip>

#include <iostream>

#include <vector>

using namespace std;

int main(){

vector<double> myvector;

double userinput;

cout<<"Enter 5 numbers: ";

for (int i = 1; i <= 5; i++){

 cin>>userinput;

    myvector.push_back(userinput);

}

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

    cout << fixed << setprecision(2)<< myvector.at(i) <<' ';

}

return 0;

}

Explanation:

This declares the vector as double

 vector<double> myvector;

This declares a variable for input as double

double userinput;

This prompts the user for input of 5 numbers

cout<<"Enter 5 numbers: ";

This iterates from 1 to 5

for (int i = 1; i <= 5; i++){

This gets each integer input

 cin>>userinput;

This pushes each input into the vector

    myvector.push_back(userinput); }

This iterates through the vector

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

This prints each vector element separated by space using fixed setprecision

cout << fixed << setprecision(2)<< myvector.at(i) <<' ';

}

You might be interested in
What are the two access modes that are used when opening a file for input and output when pickling?
san4es73 [151]

The two access modes that are used when opening a file for input and output when pickling are rb and wb.

<h3>What is pickling?</h3>

Pickle is generally used in Python to serialize and deserialize a Python object structure. In other words, it is the act of transforming a Python object into a byte stream in order to save it to a file/database, maintain program state across sessions, or transport data over a network. By unpickling the pickled byte stream, the original object hierarchy can be recreated. This entire procedure is comparable to object serialization in Java or .Net.

When a byte stream is unpickled, the pickle module first makes an instance of the original object before populating it with the right data. To accomplish this, the byte stream only carries data relevant to the original object instance.

To learn more about python visit:

brainly.com/question/13437928

#SPJ4

8 0
1 year ago
What does the acronym OSHA stand for? A. Occupational Safety and Health Administration B. Occupational Safety and Human Activiti
poizon [28]
The answer is A. Occupational Safety and health Administration.
4 0
3 years ago
Read 2 more answers
You try to enter your name into a cell that accepts a numeric value. What error would you receive
Phoenix [80]
Because it say numeric value that means numers and words/letters aren't numbers so it will say not a numeric value :) hope it helps

7 0
3 years ago
Read 2 more answers
Produce an infinite collection of sets A1,A2,A3, . . . with the property that every Ai has an infinite number of elements, Ai ∩
atroni [7]

Answer:

Produce an infinite collection of sets A1,A2,A3, . . . with the property that every Ai has an infinite number of elements, Ai ∩ Aj = ∅ for all i = j, and [infinity] i=1 Ai = N.

Explanation:

Solution

For n ∈ N,

define  A_n = {2 ^n−1  ,(3)(2n−1 ),(5)(2^n−1 ),(7)(2^n−1 ), . . .}

I.e. A_n is all odd multiples of 2^n−1 . We must show that these sets satisfy the desired properties.

• (Infinite Number of Elements).

It is clear that the set A_n = {2 ^n−1 ,(3)(2^n−1 )(5)(2^n−1 ),(7)(2^n−1 ), . . .}  has infinitely many elements.

• (Disjoint).

Given A_n and A_m with n ≠ m, we can assume, without loss of generality, that n < m. Suppose  that there existed some x ∈ A_n ∩ A_m. Then by definition of these sets, there exists some odd numbers k  and l such that x = 2^n−1 . k = 2^m−1  . l.

However since n < m, we have that n ≤ m − 1, and therefore we  can write 2^m−1 = (2^n )(2 i ) with i ≥ 0. Hence we have 2^n−1 . k = 2^n. 2 ^i. l  

Dividing both sides by 2^n−1 yields  k = (2)(2^i ) .l, which contradicts the assumption that k is odd. Therefore A_n ∩ A_m = ∅.

• (Union is N).

We want to show that  [infinity] i=1 A_n = N.

(⊆). Since each A_n is a subset of N, the union of these sets is a subset of N as well.

(⊇).Given any x ∈ N, we can write x = 2^n−1 . k for some n ∈ N where k is odd. Then x ∈ A_n, as  desired.

5 0
3 years ago
Assume that the int variables i and j have been declared, and that n has been declared and initialized.
timama [110]

Answer:

public class num6 {

   public static void main(String[] args) {

       int n = 4;

       for(int i = 1; i <= n; ++i) {

           for(int j = 1; j <= i; ++j) {

               System.out.print("* ");

           }

           System.out.println();

       }

   }

}

Explanation:

This solution is implemented in Java

Two for loops are required for this (an inner nd outer for loop).

The innner and outer for loops can be seen as implementing rows and columns (so on the first 'row' i=1, so a single star is printed, on the second row, i =2, two stars are printed and so on, all on seperate lines)

8 0
3 years ago
Other questions:
  • Which of these is an on-site metric for social media marketing?
    13·1 answer
  • An is auditor reviewing a network log discovers that an employee ran elevated commands on his/her pc by invoking the task schedu
    10·1 answer
  • Downloading files is safe for most types of files except Select one: a. documents. b. pictures. c. executable files. d. music fi
    7·1 answer
  • Write a method so that the main() code below can be replaced by simpler code that calls method calcMilesTraveled(). Original mai
    11·1 answer
  • IF U LOVE CODING CLICK HERE!!! : )
    14·1 answer
  • You have many drugs that you want to store electronically along with their purchase dates and prices, what kind of software woul
    7·1 answer
  • Please hurry!
    15·2 answers
  • Why don’t the ads on Brainly load anymore
    14·2 answers
  • Jak sie pisze oł na klawiaturze komputerowej
    11·1 answer
  • Pleaseee help me with the typical situations of the icons(i already know for words but I have no idea for giving the situations
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!