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

I\'m stuck on this particular problem, as far as the loops go. Here\'s what I ha

ID: 3550590 • Letter: I

Question

I'm stuck on this particular problem, as far as the loops go.  Here's what I have to do:

Write a program that calculates the attendance rate of this middle school. The program should


? Ask for the number of classes in this middle school

? A loop should then iterate once for each class

? During each iteration, the loop should

             ask the user for the number of students in this class,

             and the number of students who are in school today

? After all the iterations, the program should

              display the total number of student the middle school has,

              the total number of students who are in school today,

              the total number of students who are absent,

             and overall the attendance rate.


Here's what I have so far.....


import java.util.Scanner;

import javax.swing.JOptionPane;


public class ErnestTeeAttendance {


   

    public static void main(String[] args) {

     Scanner keyboard = new Scanner(System.in);   //allows for input

        

        System.out.println("Middle School

Explanation / Answer

import java.util.Scanner;

import javax.swing.JOptionPane;


/*

* Your mistake:

* 1. If you have to use JOpionPane, don't use Scanner,

* The JOptionPane will take an string argument for itself.

* Since the argument is string, ou'll have to convert them

*

* 2. Students can not be partial and so as no of classes, let them as int

* It will allow looping

*

* I did some edit to your code, works fine now.

*/

public class ErnestTeeAttendance {


public static void main(String[] args) {

JOptionPane.showMessageDialog(null,"Middle School