The Artima Developer Community
Sponsored Link

Design Forum
How To Continue With The Code for Sales Program

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
leonglkw

Posts: 43
Nickname: leonglkw
Registered: Feb, 2004

How To Continue With The Code for Sales Program Posted: Feb 22, 2004 9:47 AM
Reply to this message Reply
Advertisement
Hi guys, i have encountered the problem of conutinueing to write the code.

The required outcome of the screen should be something like this:

Item sold:-
Enter product code:c1
Enter quantity:1
More Items[Y/N]?:Y
Enter product code:p1
Enter quantity:5
More Items[Y/N]?:N

Total amount due :$2700


After the user enter the input, the data will be stored in the class variable and calculation will be done based on that.


import java.io.*;
 
class Product {
	String category;
	String favourite;
	int qtyPrepared;
	int qtySold;
	int costPrice;
	int sellingPrice;
	int difference;
}
 
class Sales {
	public static void main(String[] args) throws IOException{
		Product c1 = new Product();
		Product c2 = new Product();
		Product c3 = new Product();
		Product p1 = new Product();
		Product p2 = new Product();
		Product s1 = new Product();
		Product s2 = new Product();
 
		c1.category = "Computer";
		c1.favourite = "[c1]DELL";
		c1.qtyPrepared = 0;
		c1.qtySold = 0;
		c1.costPrice = 1000;
		c1.sellingPrice = 1700;
		c1.difference = 0;
 
		c2.category = "Computer";
		c2.favourite = "[c2]Compaq";
		c2.qtyPrepared = 0;
		c2.qtySold = 0;
		c2.costPrice = 900;
		c2.sellingPrice = 1200;
		c2.difference = 0;
 
		c3.category = "Computer";
		c3.favourite = "[c3]HP";
		c3.qtyPrepared = 0;
		c3.qtySold = 0;
		c3.costPrice = 1200;
		c3.sellingPrice = 1500;
		c3.difference = 0;
 
		p1.category = "Printer";
		p1.favourite = "[p1]Digitech";
		p1.qtyPrepared = 0;
		p1.qtySold = 0;
		p1.costPrice = 150;
		p1.sellingPrice = 200;
		p1.difference = 0;
 
		p2.category = "Printer";
		p2.favourite = "[p2]HP";
		p2.qtyPrepared = 0;
		p2.qtySold = 0;
		p2.costPrice = 180;
		p2.sellingPrice = 300;
		p2.difference = 0;
 
		s1.category = "Scanner";
		s1.favourite = "[s1]HP";
		s1.qtyPrepared = 0;
		s1.qtySold = 0;
		s1.costPrice = 100;
		s1.sellingPrice = 150;
		s1.difference = 0;
 
		s2.category = "Scanner";
		s2.favourite = "[s2]Digitech";
		s2.qtyPrepared = 0;
		s2.qtySold = 0;
		s2.costPrice = 80;
		s2.sellingPrice = 120;
		s2.difference = 0;
		
		System.out.println("Items sold:-");
		InputStreamReader productCodeReader = new InputStreamReader(System.in);
		BufferedReader inputProductCode = new BufferedReader(productCodeReader);
		System.out.print("Enter product code: ");
		String productCode = inputProductCode.readLine();
		System.out.println("Your product code: " + productCode);
 
		InputStreamReader quantityReader = new InputStreamReader(System.in);
		BufferedReader inputQty = new BufferedReader(quantityReader);
		System.out.print("Enter quqntity: ");
		String quantity = inputQty.readLine();
		System.out.println("Your quantity: " + quantity);
 
 
	}
}


Thanks, pls help...

Topic: Read/Write interfaces on data object? Previous Topic   Next Topic Topic: Software Architecture

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use