a collector wanted to create a wishlist items he wants to bu

a collector wanted to create a wishlist items he wants to buy, but when he was shopping at the online store can only be wishlist each application that he wants is to be noted for all online and offline stores. you are asked to make a program to combine the wishlist with the following conditions:
1. the user is asked to input how many kinds of items to be purchased
2. The user is prompted to input the name of the goods, the store name, price and date of purchase (repeated as many types of goods previously inputted)
3. The program will calculate the total price of goods bought
4. after all items terinput program will display all the names of goods and pricing, name store and date of purchase plus the total value of expenditure
a collector wanted to create a wishlist items he wants to buy, but when he was shopping at the online store can only be wishlist each application that he wants is to be noted for all online and offline stores. you are asked to make a program to combine the wishlist with the following conditions:
1. the user is asked to input how many kinds of items to be purchased
2. The user is prompted to input the name of the goods, the store name, price and date of purchase (repeated as many types of goods previously inputted)
3. The program will calculate the total price of goods bought
4. after all items terinput program will display all the names of goods and pricing, name store and date of purchase plus the total value of expenditure
1. the user is asked to input how many kinds of items to be purchased
2. The user is prompted to input the name of the goods, the store name, price and date of purchase (repeated as many types of goods previously inputted)
3. The program will calculate the total price of goods bought
4. after all items terinput program will display all the names of goods and pricing, name store and date of purchase plus the total value of expenditure

Solution

The above problem I have solved using java

Created one java class which contains all given attribute

Created main class which takes input from user and set the value for GOODS class attribute

Created one object of ArrayList of type Goods class

Everytime user make entries for particular goods it is stored in ArrayList object

Then in last we retrieve values from ArrayList object and print in billing format and also prints total of all goods

/* program starts */

package com;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;


public class Goods {

   String NameOfGoods;
   String StoreName;
   double Price;
   String date;
   public String getNameOfGoods() {
       return NameOfGoods;
   }
   public void setNameOfGoods(String nameOfGoods) {
       NameOfGoods = nameOfGoods;
   }
   public String getStoreName() {
       return StoreName;
   }
   public void setStoreName(String storeName) {
       StoreName = storeName;
   }
   public double getPrice() {
       return Price;
   }
   public void setPrice(double price) {
       Price = price;
   }
   public String getDate() {
       return date;
   }
   public void setDate(String date) {
       this.date = date;
   }
  
  
  
}
class Main
{
   public static double total(ArrayList<Goods> al )
   {
       double sum = 0;
       for(Goods x:al)
       {
           sum+=x.getPrice();
       }
       return sum;
   }
   public static void main(String[] args) throws IOException
   {
       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   Scanner sc = new Scanner(System.in);
   System.out.print(\"enter number of items: \");
   int N = Integer.parseInt(br.readLine());
   //sc.next();
   ArrayList<Goods> al = new ArrayList();
   while(N-->0)
   {
       System.out.println(\"enter the name of goods:\");
       String nameOfGoods = br.readLine().toString();
       System.out.println(\"enter the name of store:\");
       String storeName = br.readLine().toString();
       System.out.println(\"enter price for goods:\");
       double price = Double.parseDouble(br.readLine().toString());
       System.out.println(\"enter the date of purchase: \");
       String date = br.readLine().toString();
       Goods goods = new Goods();
       goods.setNameOfGoods(nameOfGoods);
       goods.setStoreName(storeName);
       goods.setPrice(price);
       goods.setDate(date);
       al.add(goods);
         
   }
   System.out.println(\"Name\\t\\tprice\\t\\tstore\\t\\tdate\");
   for(Goods x: al)
   {
       System.out.println(x.getNameOfGoods()+\"\\t\\t\"+x.getPrice()+\"\\t\\t\"+x.getStoreName()+\"\\t\\t\"+x.getDate());
   }
   System.out.println(\"Total:\\t\\t\\t\"+total(al));
     
   }
}

a collector wanted to create a wishlist items he wants to buy, but when he was shopping at the online store can only be wishlist each application that he wants
a collector wanted to create a wishlist items he wants to buy, but when he was shopping at the online store can only be wishlist each application that he wants
a collector wanted to create a wishlist items he wants to buy, but when he was shopping at the online store can only be wishlist each application that he wants

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site