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

Problem: Write a program that reads an unspecified number ofintegers from the ke

ID: 3613957 • Letter: P

Question

Problem: Write a program that reads an unspecified number ofintegers from the keyboard. When the user enters a '0' thissignifies the end of data entry and doesn't itself count as one ofthe entered values. The program must compute the sum of all thenumbers and the average value of the numbers. Below is a sample run of the program...display must beexact(giving the average value not in decimal form) Enter number: 35 Enter number: 12 Enter number: -3 Enter number: 0 The sume of these numbers is 44. The average of these 3 numbers is 14 and 2/3 Q: Can you give me some sort of code help to guide me in theright direction? I know I will need to use a loop, I think, I knowI will have to do sum = but dont' know much else. Help? Problem: Write a program that reads an unspecified number ofintegers from the keyboard. When the user enters a '0' thissignifies the end of data entry and doesn't itself count as one ofthe entered values. The program must compute the sum of all thenumbers and the average value of the numbers. Below is a sample run of the program...display must beexact(giving the average value not in decimal form) Enter number: 35 Enter number: 12 Enter number: -3 Enter number: 0 The sume of these numbers is 44. The average of these 3 numbers is 14 and 2/3 Q: Can you give me some sort of code help to guide me in theright direction? I know I will need to use a loop, I think, I knowI will have to do sum = but dont' know much else. Help?

Explanation / Answer

please rate - thanks import java.util.*; public class untitled {public static void main(String[] args) {int num,count=0,sum=0,whole,numerator; double average; Scanner in=new Scanner(System.in); System.out.print("Enter a number: "); num=in.nextInt(); while (num!=0)    {sum+=num;    count++;    System.out.print("Enter a number: ");    num=in.nextInt();    }    average=(double)sum/count;    System.out.println("The sum of these numbers is:"+sum);    System.out.printf("The average of the %d numbersis: %.2f ",count,average);    whole=sum/count;    numerator=sum%count;    System.out.println("Which is the same as:"+whole+" and "+numerator+"/"+count); } }

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