Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Help with Java homework

  1. #1
    Junior Member
    Join Date
    Apr 2020
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Help with Java homework

    I am having some trouble with my programming fundamentals class lab. I am getting errors and i can't figure out what is wrong. I'm not sure what the proper etiquette is for posting code so i am sorry if this goes against the proper way of doing it.

    MovieGuide.java:24: error: cannot find symbol
    numStarsString = Input.nextLine();
    ^
    symbol: variable Input
    location: class MovieGuide
    MovieGuide.java:34: error: cannot find symbol
    numStarsString = input.nextLine();
    ^
    symbol: variable input
    location: class MovieGuide
    2 errors
    Error: Could not find or load main class MovieGuide


    import java.util.Scanner;
     
    public class MovieGuide 
    {
    	public static void main(String args[])
    	{
    		Scanner s = new Scanner(System.in);
    		// 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
    		// Get input.
    		System.out.println("Enter the number of stars: ");
            numStarsString = Input.nextLine();                                                            I get an error on this line, Cannot find symbol.
     
            // This is the work done in the detailLoop() method
            numStars = Double.parseDouble(numStarsString);
    		// Convert to double.
    		// Write while loop here
    		while(numStars >=0 && numStars <= 4){
                totalStars = totalStars + numStars;
                numPatrons++;
                System.out.println("Enter the number of stars: ");
                numStarsString = input.nextLine();                                                         I get the same error on this line.
                numStars = Double.parseDouble(numStarsString);
                    // This is the work done in the detailLoop() method
    		// Convert to double.
    		numStars = Double.parseDouble(numStarsString);
            }
                    // This is the work done in the endOfJob() method
    		// Calculate average star rating
    		averageStars = totalStars / numPatrons;
    		System.out.println("Average Star Value: " + averageStars); 
     
    		System.exit(0);
    	} // End of main() method.
     
    } // End of MovieGuide class.[COLOR="Silver"]
    [/COLOR]

    --- Update ---

    Oh wow, first time posting and it looked like it was going to have the spaces in there. Sorry
    Last edited by Imeerie; April 7th, 2020 at 08:14 AM. Reason: Solved

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with Java homework

    I am getting errors
    Please copy the full text of the error messages and paste it here. It has important info about the error.

    it looked like it was going to have
    Use Go Advanced and the Preview Changes button before saving to see what will be saved on the forum.


    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    Imeerie (April 7th, 2020)

  4. #3
    Junior Member
    Join Date
    Apr 2020
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Help with Java homework

    Thanks for the quick response and the formatting information!

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with Java homework

    MovieGuide.java:24: error: cannot find symbol
    numStarsString = Input.nextLine();
    ^
    symbol: variable Input
    The compiler can not find a declaration for the variable: Input.
    Where is that variable defined? Check the code to see what the variable name should be.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #5
    Junior Member
    Join Date
    Apr 2020
    Posts
    8
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Help with Java homework

    Awesome, got it compiled and ran it with the correct results. just had to change input into the s. Thank you!

  7. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Help with Java homework

    input was a better name than s. Variable names should describe what values they contain.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java Homework
    By Dimo62 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 8th, 2013, 11:57 AM
  2. Java homework
    By Nabeel in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 24th, 2013, 09:04 AM
  3. Can you someone help me with my homework for java... Please
    By surfelijo in forum What's Wrong With My Code?
    Replies: 15
    Last Post: February 25th, 2013, 10:01 PM
  4. Replies: 8
    Last Post: February 12th, 2013, 05:45 AM
  5. New to Java. Need help with homework
    By ptison in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 26th, 2013, 05:53 PM

Tags for this Thread