Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

We have to write a small program that takes some user input(height, weight, age)

ID: 3629003 • Letter: W

Question

We have to write a small program that takes some user input(height, weight, age) and then calculates and displays some other quantities to the user(hat size, jacket size, etc).
After displaying these values to the user, the user has the option to try again and use different values. This part I understand how to do, I'll use a loop and a boolean variable that is true when the user writes "yes" when prompted.

After the user doesn't want to try anymore I have to display the largest jacket size and the second largest jacket size out of all the tries he had. This is the part I am having some difficulties, how can I keep track of all the values for jacket size? Wont the variable just be overwritten with each new try?

I dont want you to write the code for me, just give me a general direction on how to proceed. Thank you.

Explanation / Answer

please rate - thanks

use this as a same, it does just what you want

import java.util.*;
public class biggest2
{public static void main(String args[])
   {Scanner in=new Scanner(System.in);
    int count,i;
    int score, score1=-999,score2=-999;
    System.out.println("How many students do you have? ");
    count=in.nextInt();
    for(i=0;i<count;i++)
        {System.out.print("Enter student "+(i+1)+" score: ");
          score=in.nextInt();
            if(score>score1)
                {score2=score1;
                score1=score;
                }
            else if(score>score2)
                  {score2=score;
                    }
          }
    
     System.out.println("Highest score: "+score1);
    System.out.println("2nd highest score: "+score2);
    }
    }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote