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 8 of 8

Thread: Homework help!

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Homework help!

    Hi guys! total beginner here at java and need some help or guidance, I have the basic skeleton of code for this problem but am at a lost to actually knowing what to put down for the "equation". Maybe you guys can help me out?

    Sammy's Seashore Suppliers rents beach equipment such as kayaks, canoes, beach chairs, and umbrellas to tourists. Write a program that prompts the user for the number of minutes he rented a piece of equipment. Compute the rental cost as $40 per hour plus $1 per additional minute. Then display the hours, minutes, and total price. Save the file as SammysRentalPrice.java

    This is what I came up with so far:

    import java.util.Scanner;
    public class SammysRentalPrice {
     
    	public static void main(String[] args) {
     
    		int minutes;
    		int hours;
    		int additionalMinutes;
    		double price;
     
    			System.out.print("How many minutes ");
    			minutes = input.nextInt;
     
    			hours= minutes
     
    	}
     
    }
    Last edited by Taylor Swift; September 18th, 2014 at 10:22 AM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Homework help!

    What exactly are you trying to figure out? How would you figure it out with a piece of paper and a pencil, without a computer?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Sep 2014
    Posts
    21
    My Mood
    Cheeky
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Homework help!

    Can I get an autograph?
    Also could you put your code in between code tags =)

  4. #4
    Junior Member
    Join Date
    Sep 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Homework help!

    Sorry edited my post. And I'm trying to figure out how to calculate the price of the rental, by prompting the user to enter how many minutes they would be renting for, at $40 an hour, plus $1 per additional minutes. While displaying the total hours, minutes, and total price. Such as "For the rental of x hours + additional x minutes, the price is X amount.

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Homework help!

    Cool, knowing what you're trying to figure out is the first step.

    Now that you know what you're trying to figure out, which part of that are you stuck on?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #6
    Junior Member
    Join Date
    Sep 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Homework help!

    How to do the arithmetic part of it, it's just right after the system.out.print.

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Homework help!

    You have to break your problem down into smaller steps. Separate the user input from the arithmetic part.

    Since you're stuck on the arithmetic part, then simply hardcode the variables you know you're going to need to some predefined values. Then write the code that takes those variables and does the correct arithmetic with them. Which part of the arithmetic are you stuck on? How would you figure this out in your head, without a computer?

    When you get that working perfectly, then you can worry about getting the variable values from the user.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    Junior Member
    Join Date
    Sep 2014
    Posts
    21
    My Mood
    Cheeky
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Homework help!

    Like do you mean for every minute it's 1 dollar ?
    and for every hour it's 60 - 20 dollars?

    Yes there are 'better' ways to do it but it's good to start simple.
    modulos can wait.

Similar Threads

  1. Homework help please
    By hinatahyuuga1133 in forum What's Wrong With My Code?
    Replies: 12
    Last Post: October 10th, 2018, 07:30 PM
  2. Help With my Homework Please :)
    By surfelijo in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 17th, 2013, 06:32 PM
  3. Help with my homework?
    By mshem in forum Java Theory & Questions
    Replies: 2
    Last Post: November 16th, 2012, 03:15 AM
  4. Homework help?
    By regi.dg in forum Object Oriented Programming
    Replies: 0
    Last Post: October 16th, 2012, 08:17 PM
  5. Homework
    By jdonaldson in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 9th, 2011, 11:09 AM