I need help with my spacing for my code. I attached what my code is expected to look like but i guess there is a spacing error. i need to match the expected output heres my code import java.util.Scanner; public class PeopleWeights {  public static void main(String[] args) {   //object of Scanner class to read input from keyboard   Scanner kboard=new Scanner(System.in);   final int SIZE=5;   double total=0;   double average=0;   double max=0;   //create an array of size,5   double[] weights=new double[SIZE];      //Read five double values    for (int i = 0; i < weights.length; i++) {    System.out.printf("Enter weight %d : ", i+1);    weights[i]=Double.parseDouble(kboard.nextLine());    total=total+weights[i];   }//end of for loop      System.out.print("You entered: ");   for (int i = 0; i < weights.length; i++) {    System.out.printf("%.1f ", weights[i]);   }   //print the total weight value   System.out.printf("\nTotal weight: %.1f\n",total);   //calcualte average of weights   average=total/SIZE;      System.out.println("Average weight: "+average);   //Assume first element in weights array is maximum   max=weights[0];   for (int i = 0; i < weights.length; i++) {    if(weights[i]>max)     max=weights[i];   }   //print max element   System.out.printf("Max weight: %.1f\n",max);  }//end of the main method }//end of the class

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I need help with my spacing for my code. I attached what my code is expected to look like but i guess there is a spacing error. i need to match the expected output

heres my code

import java.util.Scanner;
public class PeopleWeights {
 public static void main(String[] args) {
  //object of Scanner class to read input from keyboard
  Scanner kboard=new Scanner(System.in);
  final int SIZE=5;
  double total=0;
  double average=0;
  double max=0;
  //create an array of size,5
  double[] weights=new double[SIZE];
  
  //Read five double values 
  for (int i = 0; i < weights.length; i++) {
   System.out.printf("Enter weight %d : ", i+1);
   weights[i]=Double.parseDouble(kboard.nextLine());
   total=total+weights[i];
  }//end of for loop
  
  System.out.print("You entered: ");
  for (int i = 0; i < weights.length; i++) {
   System.out.printf("%.1f ", weights[i]);
  }
  //print the total weight value
  System.out.printf("\nTotal weight: %.1f\n",total);
  //calcualte average of weights
  average=total/SIZE;
  
  System.out.println("Average weight: "+average);
  //Assume first element in weights array is maximum
  max=weights[0];
  for (int i = 0; i < weights.length; i++) {
   if(weights[i]>max)
    max=weights[i];
  }
  //print max element
  System.out.printf("Max weight: %.1f\n",max);
 }//end of the main method
}//end of the class

Output differs. See highlights below.
Special character legend
236
89.5
Input
142
166.3
93
Enter weight 1
:
Your output starts
Enter weight 2 :
Enter weight 3 :
with
Enter weight 4
:
Enter weight 5 : You entered: 236.0 89.5 142.0 166.3 93.0
Enter weight 1:
Enter weight 2:
Enter weight 3:
Expected output
Enter weight 4:
starts with
Enter weight 5:
You entered: 236.0 89.5 142.0 166.3 93.0
Transcribed Image Text:Output differs. See highlights below. Special character legend 236 89.5 Input 142 166.3 93 Enter weight 1 : Your output starts Enter weight 2 : Enter weight 3 : with Enter weight 4 : Enter weight 5 : You entered: 236.0 89.5 142.0 166.3 93.0 Enter weight 1: Enter weight 2: Enter weight 3: Expected output Enter weight 4: starts with Enter weight 5: You entered: 236.0 89.5 142.0 166.3 93.0
Special characters
Newline: Created with an expression for inserting a new line
such as \n, endlI(C++), and println(Java).
Space: An unexpected space was detected in the output.
Tab: Created with an expression for inserting a tab, such as \t.
Replacement: System is unable to render this character.
Transcribed Image Text:Special characters Newline: Created with an expression for inserting a new line such as \n, endlI(C++), and println(Java). Space: An unexpected space was detected in the output. Tab: Created with an expression for inserting a tab, such as \t. Replacement: System is unable to render this character.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY