0% found this document useful (0 votes)
7 views3 pages

Nievad UE

OOP HANDSON
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Nievad UE

OOP HANDSON
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Nieva, Michael Vernice B.

BSIT A306 OOP

class AmountDueNieva {

public double computeAmountDue(double price){

return price + (price * 0.12);

public double computeAmountDue(double price, int quantity) {

double totalPrice = price * quantity;

return totalPrice = (totalPrice * 0.12);

public double computeAmountDue(double price, int quantity, double discount) {

double totalPrice = (price * quantity);

totalPrice -= discount;

return totalPrice + (totalPrice * 0.12);

import java.util.Scanner;

public class RunAmountDueNieva {

public static void main(String[] args){

Scanner scanner = new Scanner(System.in);

AmountDueNieva amountDue = new AmountDueNieva();

System.out.println("Press any of the following then enter values separated by spaces: ");

System.out.println("1 - Price only");

System.out.println("2 - Price and Quantity");

System.out.println("3 - Price, quantity, and discount amount");


int choice = scanner.nextInt();

switch (choice) {

case 1:

System.out.println("Enter price: ");

double price = scanner.nextDouble();

double result1 = amountDue.computeAmountDue(price);

System.out.println("Amount due is " + result1);

break;

case 2:

System.out.println("Enter price and quantity: ");

price = scanner.nextDouble();

int quantity = scanner.nextInt();

double result2 = amountDue.computeAmountDue(price, quantity);

System.out.println("Amount due is" + result2);

break;

case 3:

System.out.println("Enter price, quantity, and discount amount: ");

price = scanner.nextDouble();

quantity = scanner.nextInt();

double discount = scanner.nextDouble();

double result3 = amountDue.computeAmountDue(price, quantity, discount);

System.out.println("Amount due is" + result3);

break;

default:
System.out.println("Invalid Choice");

break;

scanner.close();

You might also like