68 417
Assignments Done
Successfully Done
In December 2018

Answer to Question #58914 in Java | JSP | JSF for Nithya

Question #58914
2. Add a new fruit shop
You are required to enter information to create a new fruit shop in the system. The user must be asked to input the following:
a. Name of fruit shop
b. Current balance
c. Owner name
d. Age of owner
e. How many apples are in stock
f. The price of each apple
The ID must be auto-generated using a static variable/method. The user will not be asked for it. Try to keep the spacing as close as possible to what you see above.
Expert's answer
package javaapplication5;
public class FruitShop {
public FruitShop(String name,double balance,String ownerName,int age_Of_Owner, int Apples_in_stock, double price)
this.name = name;
this.balance = balance;
this.ownerName = ownerName;
this.age_Of_Owner = age_Of_Owner;
this.Apples_in_stock = Apples_in_stock;
this.price = price;
_id = ID;
private static int ID = 1;
private String name;
private double balance;
private String ownerName;
private int age_Of_Owner;
private int Apples_in_stock;
private double price;
private int _id;
public void printInfo()
System.out.println(name+ " "+balance+" "+ownerName+" "+this.age_Of_Owner+ " "+this.Apples_in_stock+" "+price);

package javaapplication5;
import java.util.*;
public class JavaApplication5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Name of fruit shop: ");
String name = sc.nextLine();
System.out.print("Current balance: ");
double balance = sc.nextDouble();
System.out.print("Owner name: ");
String OweName = sc.nextLine();
System.out.print(" Age of owner ");
int age = sc.nextInt();
System.out.print("How many apples are in stock ");
int apples_in_Stock = sc.nextInt();
System.out.print("The price of each apple ");
double price = sc.nextDouble();
FruitShop shop = new FruitShop(name,balance,OweName,age,apples_in_Stock,price);


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions