You are on page 1of 7

Dela Cruz, Franc Alvenn T.

BSIT 1-A

//Module 12 Activity (No.1)

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package itpacts;
import java.util.*;
/**
*
* @author user
*/
public class Module12 {

/**
* @param args the command line arguments
*/
public static void main(String[] args){
Scanner input = new Scanner(System.in);
//declaration
double x;
double total = 0;
double discount;
double dtotal;

//user input
for (int i = 10; i != 0; i--){
System.out.print("Please input price(" + i + "): ");
x = input.nextDouble();
total += x;
System.out.println("--------------------------");
System.out.println("Continue?");
System.out.println("0 or YES");
System.out.println("1 for NO");
System.out.print("Input here: ");
int _temp;
_temp = input.nextInt();
System.out.println("--------------------------");
if(_temp == 1){
break;
}
}
//computes for discount if applicable
if(total > 5000 && total < 7000.50){
discount = (total/100)*10;
dtotal = total - discount;
}else if(total >= 7000.50){
discount = (total/100)*5;
dtotal = total - discount;
}else{
discount = 0;
dtotal = total - discount;
}
//prints total, discount, and amount due
System.out.printf("Total: " + " %.2f %n", total);
System.out.printf("Discount: "+"%.2f %n",discount);
System.out.printf("Amount Due: "+"%.2f %n", dtotal);
}
}
//Module 12 Activity (No. 2)

/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
*/
package itpacts;
import java.util.*;
/**
*
* @author user
*/
public class Module12 {

/**
* @param args the command line arguments
*/
public static void main(String[] args){

//outputs table
System.out.println("-------------------------------------------------------");
System.out.println(" COURSE | AMOUNT PER UNIT | MISCELLANEOUS ");
System.out.println("-------------+---------------------+-------------------");
System.out.println(" BSCS | 890.50 | 6500.85 ");
System.out.println(" BSIT | 900.45 | 6800.89 ");
System.out.println(" BSCpe | 1010.89 | 7352.45 ");
System.out.println("-------------------------------------------------------");

//calls the method and prints the result


System.out.println("Total Amount: " + method());

} //end of main

//method with return type double


public static double method(){
Scanner input = new Scanner(System.in);

String course;
int numOfUnits;

double misc = 0;
double dAmount;
double totalAmount = 0;
double amountPerUnit;
int payMode;
//inputs course and no. of units
System.out.print("Course: ");
course = input.next();
System.out.print("Number of Units: ");
numOfUnits = input.nextInt();

switch(course){
case "BSCS", "bscs":
amountPerUnit = 890.50;
totalAmount = amountPerUnit * numOfUnits;
misc = 6500.85;
break;
case "BSIT","bsit":
amountPerUnit = 900.45;
totalAmount = amountPerUnit * numOfUnits;
misc = 6800.89;
break;
case "BSCpe","BSCPE","bscpe":
amountPerUnit = 1010.89;
totalAmount = amountPerUnit * numOfUnits;
misc = 7352.45;
break;
}

//asks for payment mode


System.out.println("----------------------------------");
System.out.println("Payment mode: ");
System.out.println("0 for cash");
System.out.println("1 for monthly");
System.out.print("Input here: ");
payMode = input.nextInt();
System.out.println("----------------------------------");

//checks if discount is applicable


if(payMode == 0){
dAmount = (totalAmount/100)*10;
totalAmount = (totalAmount - dAmount)+ misc;

}else if(payMode == 1){


dAmount = (totalAmount/100)*10;
totalAmount = (totalAmount + dAmount)+ misc;
}

// returns totalAmount
return totalAmount;
}
}

You might also like