Write a simple Java program for the scores for acourse. The program will read da
ID: 3613049 • Letter: W
Question
Write a simple Java program for the scores for acourse. The program will read data from a .txtfile. Use int for min, max, total score, and number of scores.
SampleRun
scores.txt
a12b34c56 77
BEA123nmh 100
abcdefgh1 90
Write a simple Java program for the scores for acourse. The program will read data from a .txtfile. Use int for min, max, total score, and number of scores.
Explanation / Answer
please rate - thanks import java.util.*; import java.io.*; public class untitled1 {public static void main(String[] args) {String id,minid="",maxid=""; int min=1000,max=-5,tot=0,kt=0,score; double average; Scanner input=new Scanner(new File("scores.txt")); System.out.println( "Student Score"); while(input.hasNext()) {id=input.next(); score=input.nextInt(); System.out.println(" Average: "+average+" Min: "+min+" "+minid+"Max: "+max+" "+maxid); System.out.printf(" Average: %10.7f Min: %d %s Max:%d %s ",average,min,minid,max,maxid); } } I've included 2 types of print statements, and printed the outputtwice System.out.println(" Average: "+average+" Min: "+min+" "+minid+"Max: "+max+" "+maxid); System.out.printf(" Average: %10.7f Min: %d %s Max:%d %s ",average,min,minid,max,maxid); choose the 1 you like better
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.