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
lianna [129]
3 years ago
5

Prompt the user to enter four numbers, each corresponding to a person's weight in pounds. Store all weights in a list. Output th

e list. (2 pts)
Ex:

Enter weight 1:
236.0
Enter weight 2:
89.5
Enter weight 3:
176.0
Enter weight 4:
166.3
Weights: [236.0, 89.5, 176.0, 166.3]
(2) Output the average of the list's elements with two digits after the decimal point. Hint: Use a conversion specifier to output with a certain number of digits after the decimal point. (1 pt)

(3) Output the max list element with two digits after the decimal point. (1 pt)
Computers and Technology
1 answer:
Lesechka [4]3 years ago
6 0

Answer:

# FIXME (1): Prompt for four weights. Add all weights to a list. Output list.

weight_one=float(input('Enter weight 1:\n'))

weight_two=float(input('Enter weight 2:\n'))

weight_three=float(input('Enter weight 3:\n'))

weight_four=float(input('Enter weight 4:\n'))

weights=[weight_one,weight_two,weight_three,weight_four]

print(weights)

# FIXME (2): Output average of weights.

average_weight=(weight_one + weight_two + weight_three + weight_four) / 4

print('Average weight:', "%.2f" % average_weight)

# FIXME (3): Output max weight from list.

weights.sort()

max_weight= weights[3]

print('Max weight:', "%.2f" % max_weight)

# FIXME (4): Prompt the user for a list index and output that weight in pounds and kilograms.

print(input('Enter a list index location (0 - 3):'))

print('Weight in pounds:', weights)

kilograms = float(weights) * 2.2

print('Weight in kilograms:')

# FIXME (5): Sort the list and output it.

weights.sort()

print(weights)

Explanation:

You might be interested in
Write a program, named sortlist, that reads three to four integers from the command line arguments and returns the sorted list o
yawa3891 [41]

Answer:

In C++:

void sortlist(char nums[],int charlent){    

   int Myarr[charlent];

const char s[4] = " ";  

char* tok;  

tok = strtok(nums, s);  

int i = 0;  

while (tok != 0) {  

 int y = atoi(tok);

 Myarr[i] = y;

 tok = strtok(0, s);  

 i++;

}  

int a;  

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

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

 if (Myarr[i] > Myarr[j]) {

  a =  Myarr[i];

  Myarr[i] = Myarr[j];

  Myarr[j] = a;

       }   }  }

 

for(int j = 0;j<charlent;j++){ printf(" %d",Myarr[j]); }  

}

Explanation:

This line defines the sortlist function. It receives chararray and its length as arguments

void sortlist(char nums[],int charlent){    

This declares an array

   int Myarr[len];

This declares a constant char s and also initializes it to space

const char s[4] = " ";  

This declares a token as a char pointer

char* tok;

This line gets the first token from the char

tok = strtok(nums, s);

This initializes variable i to 0

int i = 0;

The following while loop passes converts each token to integer and then passes the tokens to the array  

<em> while (tok != 0) {  </em>

<em>  int y = atoi(tok); </em><em>-> Convert token to integer</em><em> </em>

<em>  Myarr[i] = y; </em><em>-> Pass token to array</em><em> </em>

<em>  tok = strtok(0, s); </em><em>-> Read token</em><em> </em>

<em>  i++; </em>

<em> }  </em>

Next, is to sort the list.

int a;

This iterates through the list  

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

This iterates through every other elements of the list

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

This condition checks if the current element is greater than next element

 if (Myarr[i] > Myarr[j]) {

If true, swap both elements

<em>   a =  Myarr[i]; </em>

<em>   Myarr[i] = Myarr[j]; </em>

<em>   Myarr[j] = a; </em>

       }   }  }

The following iteration prints the sorted array

<em>for(int j = 0;j<charlent;j++){ printf(" %d",Myarr[j]); }  </em>

}

<em>See attachment for illustration of how to call the function from main</em>

Download cpp
7 0
3 years ago
Write an application that displays a series of at least five student ID numbers (that you have stored in an array) and asks the
babymother [125]

Answer:

See explaination for the program code

Explanation:

// ScoreException.java

class ScoreException extends Exception

{

ScoreException(String msg)

{

super(msg);

}

}

// TestScore.java

import java.util.Scanner;

public class TestScore

{

public static void main(String args[]) throws ScoreException

{

Scanner sc = new Scanner(System.in);

int studentId[] = { 1201, 1202, 1203, 1204, 1205 };

int scores[] = new int[5];

int score = 0;

for(int i = 0; i < studentId.length; i++)

{

try

{

System.out.print("Enter a numeric test score for the student"+(i+1)+" of Id "+studentId[i]+" : ");

score = sc.nextInt();

if(score < 0 || score > 100)

{

scores[i] = 0;

throw new ScoreException("Input should be between 1 and 100");

}

else

{

scores[i] = score;

}

}

catch(ScoreException ex)

{

System.out.println("\n"+ex.getMessage()+"\n");

}

}

//displaying student details

System.out.println("\n\nStudent Id \t Score ");

System.out.println("=============================");

for(int i = 0; i < studentId.length; i++)

{

System.out.println(studentId[i]+"\t\t"+scores[i]);

}

}

}

8 0
3 years ago
Tdd does not help in detection of bugs at an early development stages of sdlc
Sav [38]

The statement is false. TDD can help detect bugs in the early stages in developing SDLC. TDD is a software that is often more productive than a debugging software. Since it requires developers the ability to take small steps first, by detecting bugs in the early stages it can help finesse the SDLC and other tests.

4 0
3 years ago
Which type of worker has a career that can be important in both maintenance/operations services and construction services? mecha
Evgesh-ka [11]

<u>Answer is:</u>

construction managers


<u>Explanation:</u>

why this answer because managers are manages the whole things and do check on every thing that can happened in services of maintenance and operations. So that is why this is the answer for this question.

I hope you get the idea. Thanks

3 0
3 years ago
Read 2 more answers
The word font refers to the style of lettering but not the color.<br> true or false
Lilit [14]
The answer for this  is true .
5 0
3 years ago
Read 2 more answers
Other questions:
  • A personal computer uses a number of chips mounted on a circuit board called microprocessor. system board. daughter board. mothe
    8·1 answer
  • What kind of voltage do solar cells generate? Solar cells produce ______ voltage which is not usable by most household appliance
    15·1 answer
  • File Explorer contains ribbon tabs that can be used for various functions. Which ribbon tab provides options to open a new File
    11·1 answer
  • What are considered to be among the earliest adhesives?
    15·1 answer
  • A ____________object appears on a form as a button with a caption written across its face.
    7·1 answer
  • Ming's computer crashed suddenly the other day. Ming kept trying the solution that worked last few times it had crashed, even th
    11·1 answer
  • The force required to slide an object is equal to _____.
    13·1 answer
  • You are implementing a RAID storage system and have found a system with eight 100 GB drives. How much storage space will you hav
    5·1 answer
  • Pleaseeeeeeee tellllllllllllllllllllll​
    8·1 answer
  • Given the following declaration, what is the value of b[ 1 ][ 0 ]? int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } };
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!