0% found this document useful (0 votes)
10 views

Finals Syntax Modified

A long definition is an expanded explanation of a term or concept that goes beyond a simple dictionary definition. It provides a detailed description, often including various aspects of the term's meaning, context, function, and implications. This type of definition might include background information, examples, applications, and the broader context in which the term is used. Long definitions are particularly useful when explaining complex or abstract terms that may require additional context t

Uploaded by

saimond lin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Finals Syntax Modified

A long definition is an expanded explanation of a term or concept that goes beyond a simple dictionary definition. It provides a detailed description, often including various aspects of the term's meaning, context, function, and implications. This type of definition might include background information, examples, applications, and the broader context in which the term is used. Long definitions are particularly useful when explaining complex or abstract terms that may require additional context t

Uploaded by

saimond lin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

import java.text.

DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
public class modification {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

//database
ArrayList<String> orderSummary = new ArrayList<>();
ArrayList <String> product_list = new ArrayList<>();
ArrayList <Double> product_price= new ArrayList<>();

//calendar
DateFormat date = new SimpleDateFormat("MM-DD-YYYY");
DateFormat time = new SimpleDateFormat("HH:mm:ss");
Date cal = new Date();

//public datatypes
double total=0;
String searchProduct;
int product_loop = 0;
int loop = 0;
boolean found = false;

do{
System.out.println("===================================");
System.out.println(" POS - PROGRAM ");
System.out.println("===================================");
System.out.println("Task: ");
System.out.println(" A - Add a Product");
System.out.println(" v - View Product");
System.out.println(" D - Delete a Product");
System.out.println(" T - Transact Sales");
System.out.println(" [ANY KEY] - Exit");
System.out.println(" ");
System.out.print("Chosen task is: ");
String task = sc.nextLine();

if(task.equalsIgnoreCase("a")){

System.out.println("===================================");
System.out.println(" < Add a Product > ");
System.out.println("===================================");
System.out.println(" ");
System.out.println("Date and Time :" + date.format(cal) + " "
+time.format(cal) );
System.out.println(" ");

System.out.print("Product Name: ");


String pn = sc.nextLine();

System.out.print("Product Price: ");


try{
double pp =sc.nextDouble();
product_list.add(pn);
product_price.add(pp);
sc.nextLine();

System.out.println(" ");
System.out.println("The product is ADDED to the system");
System.out.println(" ");

}catch(InputMismatchException ex){
sc.nextLine();
System.out.println(" ");
System.out.println(" ");
System.out.println("The Product NOT ADDED, Invalid Price!
");
System.out.println(" ");
}

}else if(task.equalsIgnoreCase("v")){
System.out.println("===================================");
System.out.println(" < View Product > ");
System.out.println("===================================");
System.out.println(" ");
System.out.println("Date and Time :" + date.format(cal) + " "
+time.format(cal) );

if (product_list.size() == product_price.size()) {
for (int i = 0; i < product_list.size(); i++) {
System.out.println(" ");
System.out.println("Product Name: "
+product_list.get(i));
System.out.println(" Product Price: " +
product_price.get(i));
System.out.println(" ");
}
}

}else if(task.equalsIgnoreCase("d")){

System.out.println("===================================");
System.out.println(" < Delete a Product > ");
System.out.println("===================================");
System.out.println(" ");
System.out.println("Date and Time :" + date.format(cal) + " "
+time.format(cal) );
System.out.println(" ");
System.out.print("Product Name: " );
searchProduct = sc.nextLine();

if (product_list.size() == product_price.size()) {
for (int i = 0; i < product_list.size(); i++) {

if(product_list.get(i).equalsIgnoreCase(searchProduct)){
product_list.remove(i);
product_price.remove(i);
found = true;
}else{
found = false;
}
}
}

if (found == true){
System.out.println(" ");
System.out.println("The Product DELETED from the system!"
);
System.out.println(" ");
System.out.println(" ");
}else{
System.out.println(" ");
System.out.println("The Product does NOT EXIST!" );
System.out.println(" ");
System.out.println(" ");
}

}else if(task.equalsIgnoreCase("t")){

System.out.println("===================================");
System.out.println(" < Transact Sales > ");
System.out.println("===================================");
System.out.println(" ");
System.out.println("Date and Time :" + date.format(cal) + " "
+time.format(cal) );
System.out.println(" ");
System.out.println(" ");

do{
System.out.print("Product Name(type 'X' to STOP the
transaction): " );
searchProduct = sc.nextLine();

if (product_list.size() == product_price.size()) {
for (int i = 0; i < product_list.size(); i++) {

if(product_list.get(i).equalsIgnoreCase(searchProduct)){
total = total + product_price.get(i);
orderSummary.add(" "+product_list.get(i)+"
- "+product_price.get(i));
found = true;
break;
}else{
found = false;
}

}
}

if(!found){
System.out.println("The Product does NOT EXIST!");
}

if(searchProduct.equalsIgnoreCase("X")){
System.out.println("=============================");
System.out.println("Total cost: " + total);

System.out.println(" ");
System.out.println(" ");
System.out.println("Transactionn Details:");
System.out.println(" ");
System.out.println("Date and Time :" + date.format(cal) +
" " +time.format(cal) );
System.out.println(" ");
System.out.println("Item an Prices:");
for (String item : orderSummary) {
System.out.println(item);
product_loop++;
}

System.out.println("Total Cost: " + total );


product_loop = 1;

}
}while(product_loop != 1);

}else{
System.out.println(" ");
System.out.println("All Transactionn Logs:");
System.out.println(" ");
System.out.println("Date and Time :" + date.format(cal) +
" " +time.format(cal) );
System.out.println(" ");
System.out.println("Item an Prices:");

for (String item : orderSummary) {


System.out.println(item);
}

System.out.println("Total Cost: " + total );


System.out.println(" ");
System.out.println("THANK YOU FOR USING THIS POS -
PROGRAM!");
loop =1;
}

}while(loop !=1 );

}
}

You might also like