You are on page 1of 4

FEU Institute of Technology

ITE Department Object Oriented Programming 1 – Machine Problem

Name: Ong,Paul Lawrenz Date Performed: 01/03/2019

Course/Yr: BSIT-SMBA /3rd Year Date Submitted: 01/03/2019

Class Schedule: 16:00-18:50 hrs Score: __________________

Machine Problem # 2

Savings Calculator

INSTRUCTION

1. Write a program will compute the savings of student weekly allowance.

2. The program will include basic input/output and using Java operators.

OUTPUT

Student Name:

Student Number:

No. of Days/Week:

ALLOWANCE:

EXPENSES

Fare:

Food:

Other:

Expenses:

Total Expenses:

Savings:
FEU Institute of Technology
ITE Department Object Oriented Programming 1 – Machine Problem

Source Code:

import java.util.*;

public class MachineProblem2

public static void main (String args[])

System.out.println(" I N F O R M A T I O N S Y S T E M ");

System.out.println("========================================");

Scanner input = new Scanner(System.in);

//declaration of variables

String name;

int number, days ;

double allowance,fare,food,otherexpenses,totalexpense;

//Input Output

System.out.print("Enter Student Name: ");

name = input.nextLine();

System.out.println("Happy New Year " + name + "!");

System.out.print("Enter Student Number: ");

number = Integer.parseInt(input.nextLine());

System.out.print("Enter No. of Days/Week: ");


FEU Institute of Technology
ITE Department Object Oriented Programming 1 – Machine Problem

days= Integer.parseInt(input.nextLine());

System.out.print("Enter Allowance (in Philippine Peso): ");

allowance = Double.parseDouble(input.nextLine());

System.out.println();

System.out.println("========================================");

System.out.println("\t\tEXPENSES ");

System.out.print("Enter Fare Expense: ");

fare = Double.parseDouble(input.nextLine());

System.out.print("Enter Food Expense: ");

food = Double.parseDouble(input.nextLine());

System.out.print("Enter Other Expenses: ");

otherexpenses = Double.parseDouble(input.nextLine());

double sum;

sum = fare + food + otherexpenses;

System.out.println("Total Expenses:" + sum );

System.out.println("========================================");

double savings;

savings = allowance - sum;

System.out.println("Total Savings:" + savings );

}
FEU Institute of Technology
ITE Department Object Oriented Programming 1 – Machine Problem

OUTPUT:

You might also like