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

Thread: Help with Java word problem

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

    Default Help with Java word problem

    Im really stuck on this probably easy word problem to you guys but I just started so Im fairly new to all of this

    Here is the problem, Meadowdale Dairy Farm sells organic brown eggs to local customers. They charge $3.25 for a dozen eggs, or 45 cents for individual eggs that are not part of a dozen. Write a class that prompts a user for the number of eggs in the order and then display the amount owed with a full explanation. For example, typical output might be, “You ordered 27 eggs. That’s 2 dozen at $3.25 per dozen and 3 loose eggs at 45 cents each for a total of $7.85.” Save the class as Eggs.java

    Here is what I have so far
    import java.util.Scanner;
    public class Eggs {

    public static void main(String[] args) {
    final double PRICEOFSINGLEGGS = 0.45;
    final double PRICEOFDOZENEGGS = 3.25;
    Scanner input = new Scanner(System.in);
    int eggs;


    System.out.print("Enter number of eggs needed >> ");
    eggs = input.nextInt();
    int dozeneggs = eggs/12;
    int remainder = eggs%12;
    System.out.println("The number entered was " + eggs);

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,459
    Thanks
    52
    Thanked 2,313 Times in 2,269 Posts

    Default Re: Help with Java word problem

    What specific java programming problems are you having with the program you are trying to write?

    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.

Similar Threads

  1. word game (problem how to check that the word is in the dictionary)
    By Rabia in forum What's Wrong With My Code?
    Replies: 20
    Last Post: April 28th, 2014, 11:05 AM
  2. Replies: 3
    Last Post: December 13th, 2013, 07:36 AM
  3. Replies: 7
    Last Post: March 29th, 2013, 08:38 AM
  4. Replies: 5
    Last Post: August 20th, 2012, 02:01 AM
  5. Need help in analyzing this word problem.
    By daveewhit in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 29th, 2010, 08:36 AM