Q&A: how to i fix this java, it doesn’t do what i want ?
Question by lookadistraction: how to i fix this java, it doesn’t do what i want ?
class Movie
{
String title;
String genre;
int rating;
}
class MovieTestDrive
{
public static void main( String[] args )
{
Movie[] movi = new Movie[10];
movi[0] = new Movie( );
movi[0].title = “Harry Potter,”;
movi[0].genre = “fantasy, “;
movi[1] = new Movie( );
movi[1].title = “James Bonds,”;
movi[1].genre = “action, “;
movi[2] = new Movie( );
movi[2].title = “Home alone,”;
movi[2].genre = “comedy, “;
movi[3] = new Movie( );
movi[3].title = “Star wars,”;
movi[3].genre = “scifi, “;
movi[4] = new Movie( );
movi[4].title = “March of the penguins,”;
movi[4].genre = “Documentary, “;
movi[5] = new Movie( );
movi[5].title = “The day after tomorrow,”;
movi[5].genre = “scifi, “;
movi[6] = new Movie( );
movi[6].title = “101 dalmations,”;
movi[6].genre = “action, “;
movi[7] = new Movie( );
movi[7].title = “Dark Knight,”;
movi[7].genre = “action, “;
movi[8] = new Movie( );
movi[8].title = “Spiderman,”;
movi[8].genre = “action, “;
movi[9] = new Movie( );
movi[9].title = “The ring,”;
movi[9].genre = “horror, “;
String hrm =”Highest rated movie: ” ;
for ( int x=0; x<10; x++ )
{
movi[x].rating = ( int )( Math.random( )*10 )+1;
System.out.println( "Movie: " + movi[x].title + " Genre:" + movi[x].genre + "Rating:"+movi[x].rating );
}//end for loop
int max =0;
int himov=0;
for ( int x=0; x<10; x++ )
{
if ( max
Answer by deonejuan
class Movie {
String title;
String genre;
double rating;
public Movie( String t, String g) {
title = t;
genre = g;
rating = 0.0;
}
//================
class TestMovie {
public static void main(String[] args) throws Exception {
Movie[] movi = new Movie[10]; What do you think? Answer below!
movi[0] = new Movie(“Deep Throat”,”porno”);
movi[1] = new Movie(“Debbie does Dallas”, “family”);
movi[2] = new Movie(“Bambi”,”comedy”);
…
for( int i = 0; i