Java Program Grocery Receipt

Java

  1. Java Program Grocery Receipt Example
  2. Java Program Grocery Receipt Examples
  3. Java Program Grocery Receipts
  4. Java Program Grocery Receipt Template
Java program grocery receipt example

Need Receipt is an online receipt generator. Create itemized designs for a wide array of vendors including: restaurant receipt‚ bar receipt‚ retail store receipt‚ gas station receipt‚ taxi receipt‚ pharmacy receipt and itemized grocery receipts. Looking for some help on a project where I need to make a recipe book with the follow features: 1. List all recipes. Display a single recipe. Search and return recipes with a single ingredient. I tried below using a hashmap, for the recipe name and ingredients:?

Java Program Grocery Receipt Example

Hello Friends. I am working in a Java assignment and I am seriously in need of a help. Since I am new to programming, I need an assist. The program which I have to do has the following specifications:
Scanners should be used compalsarily
The green grocer has asked you to write a program to help him manage the sales of his fruit and vegetables.
You are to write a Java Console Application (FruitVegShop.class) which will allow him to enter the name of the customer then enter the details of N produce purchases. N should be equal to the highest digit in your student ID, use N=3 if your highest digit is less than three. For each produce purchase the program will prompt for and accept the name of the produce, the weight of the produce in kilograms and the price per kilogram.
The required Java Console Application should allow the user to: 1. Enter the Customer name. For each of the N purchases 2. Enter the Name of the produce. 3. Enter the Weight of the produce in kilograms. 4. Enter the Price per kilogram 5. The application will calculate and display the weight, name, price per kg and the total cost of the purchase.
2.30 kgs of apples at $3.40 per kg is $7.82
The program will number each purchase
6. When N purchases have been entered the user will enter if the customer is eligible for a discount (students and pensioners), if the customer is eligible for a discount they will receive 10% of the final price. 7. Finally the customer name, number of purchases and the total costs paid will be displayed (see sample output below). 8. Display the discount amount only if the customer is eligible. 9. Display a welcome message at the beginning “Welcome to Rocky Fruit and Vegetable Market” and an end message e.g. “Thank you <customer name> for shopping at the Rocky Fruit and Vegetable Market” and the final line “Written by <your student ID>” (see sample output below).
All numeric literal values i.e. N and DISCOUNT must be represented as constants.

  • 3 Contributors
  • forum2 Replies
  • 2,805 Views
  • 4 Hours Discussion Span
  • commentLatest PostLatest Postby JerrimePatient

Recommended Answers

DaniWeb Member Rules (which you agreed to when you signed up) include:
'Do provide evidence of having done some work yourself if posting questions from school or work assignments'
'>http://www.daniweb.com/community/rules

Post what you have …

Jump to Post

All 2 Replies

JamesCherrill4,394Most Valuable Poster ModeratorFeatured Poster

DaniWeb Member Rules (which you agreed to when you signed up) include:
'Do provide evidence of having done some work yourself if posting questions from school or work assignments'
'>http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

(Invoice Class) Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables—a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method for each instance variable. In addition, provide a method named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value. If the quantity is not positive, it should be set to 0. If the price per item is not positive, it should be set to 0.0. Write a test application named InvoiceTest that demonstrates class Invoice’s capabilities.

Answer:

class Invoice{
// Declare instance variables
String number;
String description;
int quantity;
double price;

// Constructor for variables’ initialization
Invoice(String n, String d, int q, double p){
number = n;
description = d;
quantity = q;
price = p;
}

// Set method
void setNumber(String n){
number = n;
}
void setDescription(String d){
description = d;
}
void setQuantity(int q){
quantity = q;
if(q < 0)
quantity = 0;
}
void setPrice(double p){
price = p;
if(p < 0)
price = 0.0;
}

// Get method
String getNumber(){
return number;
}
String getDescription(){
return description;
}
int getQuantity(){
return quantity;
}
double getPrice(){
return price;
}

// getInvoiceAmount method
double getInvoiceAmount(){
return quantity*price;
}
}

Java Program Grocery Receipt Examples

class InvoiceTest{
public static void main(String[] args){
// Create Object(s)
Invoice object1 = new Invoice(“27”, “Blueberry parfait”, 3, 9.9);
Invoice object2 = new Invoice(“12”, “Rainbow Fraffucino”, 5, 6.6);
Invoice object3 = new Invoice(“94”, “Strawberry shortcake”, 7, 29.8);

Java Program Grocery Receipts

// Print the Invoice
System.out.println(“This is an Invoice for the Item(s) Sold:” + “n”);
System.out.println(object1.getNumber() + “t” + object1.getDescription() + “t” + object1.getQuantity() + “t” + object1.getPrice() + “t” + object1.getInvoiceAmount());

System.out.println(object2.getNumber() + “t” + object2.getDescription() + “t” + object2.getQuantity() + “t” + object2.getPrice() + “t” + object2.getInvoiceAmount());

System.out.println(object3.getNumber() + “t” + object3.getDescription() + “t” + object3.getQuantity() + “t” + object3.getPrice() + “t” + object3.getInvoiceAmount());

System.out.println(“n”);

Java Program Grocery Receipt Template

Java program grocery receipts

double total = object1.getInvoiceAmount() + object2.getInvoiceAmount() + object3.getInvoiceAmount();
System.out.println(“TOTAL: “+ total + “nn”);
}
}