// MovieGuide.java - This program allows each theater patron to enter a value from 0 to 4
// indicating the number of stars that the patron awards to the Guide's featured movie of the
// week. The program executes continuously until the theater manager enters a negative number to
// quit. At the end of the program, the average star rating for the movie is displayed.
import javax.swing.JOptionPane;
public class MovieGuide2
{
public static void main(String args[])
{
// Declare and initialize variables.
double numStars; // star rating.
String numStarsString; // string version of star rating
double averageStars; // average star rating.
double totalStars = 0; // total of star ratings.
int numPatrons = 0; // keep track of number of patrons
// This is the work done in the housekeeping() method
{
numStarsString = JOptionPane.showInputDialog ("Enter Number of Stars between 1 and 4: ");// Get input.
// This is the work done in the detailLoop() method
numStars = Double.parseDouble (numStarsString); // Convert to double.
while (numStars > 0) // Write while loop here
{
totalStars =+ numStars;
System.out.println ("Number of Patrons Responding: " + numPatrons);
numPatrons ++;
System.out.println ("Number of Stars Given: " + numStars);
numStarsString = JOptionPane.showInputDialog ("Enter Number of Stars between 1 and 4: ");// Get input.
{
if (totalStars == -1)
{
averageStars = (totalStars/numPatrons); // Calculate average star rating
System.out.println("Average Star Value: " + averageStars);
}
}
}
// This is the work done in the endOfJob() method
System.out.println ("End of File");
}
System.exit(0);
} // End of main() method.
} // End of MovieGuide class.
It's not missing a curly brace because it submitted when I was making some adjustments. - sorry about that.
Quote
It is NOW missing a curly brace because it submitted when I was making some adjustments. Sorry....
This post has been edited by jon.kiparsky: 12 October 2012 - 09:34 AM
Reason for edit:: fixed code tags - [/code], not [END CODE]

New Topic/Question
Reply




MultiQuote




|