Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class MealCard{
- static int initial_Balance=200;
- private String Student_Name;
- private int Student_ID;
- private int costofitem;
- Scanner SC=new Scanner(System.in);
- public MealCard(){
- Student_Name=SC.nextLine();
- Student_ID=SC.nextInt();
- costofitem=SC.nextInt();
- System.out.println("The student's name: "+ Student_Name);
- System.out.println("Student ID number: "+ Student_ID);
- System.out.println("Initial Balance : "+ MealCard.getInitial_Balance());
- if(getPay(costofitem)>5){
- System.out.println("Payment accepted! Your final balance is: "+ getPay(costofitem));}
- }
- public static int getInitial_Balance() {
- return initial_Balance;
- }
- public static int getPay(int a) {
- int finalbalance = initial_Balance - a;
- if(finalbalance<5){
- System.out.println("This is too low of a balance! Payment Rejected!");
- System.out.println("Warning: balance is too low! Must deposit more money into school account.");
- }
- else;
- return finalbalance;
- }}
- public class Homework4Question3{
- public static void main(String[] args ){
- NameTag();
- for(int i=0;i<5;i++){
- System.out.println("Please enter the name of the student, the ID, and the cost of the item you want.");
- MealCard StudentMealPlan=new MealCard();}
- }
- public static void NameTag(){
- System.out.println("Malachi Sor Homework 4 Question 3\n--------------------------\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment