Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi I have been working on this assignment for the class Programming in Java for

ID: 3561485 • Letter: H

Question

Hi I have been working on this assignment for the class Programming in Java for a few days now and I am so lost. This is the assignment:

Create a Java application that will calculate the cost of eggs. The cost per dozen is $3.00. Each individual egg is 30 cents. Display an input dialog box asking the user to enter the number of eggs purchased. Store this value in a variable. Convert it from a String to a number so it can be used in a calculation. Make the cost per dozen and the cost per egg named constants

Below is exactly what my input and the output should look like after creating the java application.

Sample Input

Sample Output

I know this is extremely off but this is so far what i havebeen able to come up with. I am having an issue making this into an input dialog box. Any help would be highly appreciated. Thank You;)

import java.util.Scanner;
import javax.swing.JOptionPane;


public class eggs
{
public static void main(String args[])
{

Scanner sc = new Scanner(System.in);
System.out.print("Enter number of Eggs you purchased : ");
int numOfEggs = sc.nextInt();


int extra = numOfEggs%12;

double ecost = (double)extra * 30 / 100;

double cost = numOfEggs/12 * 3.00 + ecost;
System.out.println("The total price of your eggs is "+cost+"");

}

}

Explanation / Answer

import java.util.Scanner;
public class EggBasket
{
public static void main(String[] args)
{
double numofeggs, ecost, extra, cost;
Scanner keyboard = new Scanner(System.in);
System.out.print( "Enter the number of eggs you purchased: ");
numofeggs = keyboard.nextInt();
extra = numofeggs%12;
ecost = (extra*30)/100;
cost = ((numofeggs/12)*3)+ecost;
System.out.println("Total price of your eggs is " + cost);
}
}