What's new

Closed I really need some wisdom about this :(

Status
Not open for further replies.
Joined
Feb 18, 2017
Posts
53
Reaction
5
Points
80
Good day ka PHC... Sana po may makatulong po sa problema ko.. hanggang bukas nalng po ito ma susubmit ;(

Write a program that displays random ID numbers and 5 random scores 1 - 20 for each randomly generated ID numbers and sums up the score of every ID numbers. Print the ID number of the highest scorer and the lowest scorer..

Example:

ID NUMBER....Score1...Score2..Score3..Score4...Score5....Total
1111111...............20..........20..........20...........20.........20.........100
1111110..............20..........20...........20..........20..........20.........100
222222................1............1..............1...........1...........1.............5


Highest scorer................Score
1111111...........................100
1111110...........................100
Lowest scorer................Score
222222..............................5
 
Please put it on correct Formation I can't understand it must be a formation if u reply I'll answer it
 
Please put it on correct Formation I can't understand it must be a formation if u reply I'll answer it

Solved na po sir.. thanks to ms. FreeAllYouCan

Eto po code niya

Code:
import java.util.Random;

public class RandomIDandScoreGenerator {

   public static void main(String[] args) {
      Random rnd = new Random();
      int sum;
      int[][] table = new int[10][6];
      int[] score = new int[table.length];
      //Generates and prints out the random ID's
      //with their corresponding scores
      System.out.printf("%s%10s%10s%10s%10s%10s%10s\n","ID NUMBER","Score1","Score2","Score3","Score4","Score5","Total");
      for (int i = 0; i < 10; i++) {
         table[i][0] = 10000000 + (rnd.nextInt(9999999)); //randomly generated ID numbers
         System.out.printf("%d", table[i][0]);
         sum = 0;
         for (int j = 1; j < table[i].length; j++) {
            table[i][j] = 1 + (rnd.nextInt(21)); //randomly generated scores from 1 - 20
            System.out.printf("%10d", table[i][j]);
            sum += table[i][j];
         }
         score[i] = sum;
         System.out.printf("%10d", score[i]);
         System.out.println();
      }
      int highestScore, lowestScore;
      highestScore = score[0];
      lowestScore = score[0];
      //Determine the highest and lowest score
      for (int i = 1; i < score.length; i++) {
         if (score[i] >= highestScore) {
            highestScore = score[i];
         }
         if (score[i] <= lowestScore) {
            lowestScore = score[i];
         }
      }
      //Prints out the highest scorer
      System.out.printf("\n\n%s%37s\n","Student/s with the highest score","Score");
      for (int i = 0, ctr = 1; i < score.length; i++) {
         if (highestScore == score[i]) {
            System.out.printf("%d%c%d%58d\n",ctr,'.',table[i][0],highestScore);
            ctr++;
         }
      }
      //Prints out the lowest scorer
      System.out.printf("\n\n%s%37s\n","Student/s with the lowest score","Score");
      for (int i = 0, ctr = 1; i < 10; i++) {
         if (lowestScore == score[i]) {
            System.out.printf("%d%c%d%58d\n",ctr,'.',table[i][0],lowestScore);
            ctr++;
         }
      }
   }//end of main
}//end of class
 
Explain it further !

Explain it further !

Solved na po sir. Thanks to ms. FreeAllYouCan

Eto po code nya

Code:
import java.util.Random;

public class RandomIDandScoreGenerator {

   public static void main(String[] args) {
      Random rnd = new Random();
      int sum;
      int[][] table = new int[10][6];
      int[] score = new int[table.length];
      //Generates and prints out the random ID's
      //with their corresponding scores
      System.out.printf("%s%10s%10s%10s%10s%10s%10s\n","ID NUMBER","Score1","Score2","Score3","Score4","Score5","Total");
      for (int i = 0; i < 10; i++) {
         table[i][0] = 10000000 + (rnd.nextInt(9999999)); //randomly generated ID numbers
         System.out.printf("%d", table[i][0]);
         sum = 0;
         for (int j = 1; j < table[i].length; j++) {
            table[i][j] = 1 + (rnd.nextInt(21)); //randomly generated scores from 1 - 20
            System.out.printf("%10d", table[i][j]);
            sum += table[i][j];
         }
         score[i] = sum;
         System.out.printf("%10d", score[i]);
         System.out.println();
      }
      int highestScore, lowestScore;
      highestScore = score[0];
      lowestScore = score[0];
      //Determine the highest and lowest score
      for (int i = 1; i < score.length; i++) {
         if (score[i] >= highestScore) {
            highestScore = score[i];
         }
         if (score[i] <= lowestScore) {
            lowestScore = score[i];
         }
      }
      //Prints out the highest scorer
      System.out.printf("\n\n%s%37s\n","Student/s with the highest score","Score");
      for (int i = 0, ctr = 1; i < score.length; i++) {
         if (highestScore == score[i]) {
            System.out.printf("%d%c%d%58d\n",ctr,'.',table[i][0],highestScore);
            ctr++;
         }
      }
      //Prints out the lowest scorer
      System.out.printf("\n\n%s%37s\n","Student/s with the lowest score","Score");
      for (int i = 0, ctr = 1; i < 10; i++) {
         if (lowestScore == score[i]) {
            System.out.printf("%d%c%d%58d\n",ctr,'.',table[i][0],lowestScore);
            ctr++;
         }
      }
   }//end of main
}//end of class
 
Status
Not open for further replies.
Back
Top