Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test;
- import java.util.Scanner;
- public class Exercise1 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner s = new Scanner(System.in);
- // Define variables
- int NumOfRooms;
- int NumofDays;
- double Price;
- boolean IsDuplex = false;
- char Duplex;
- //Set the input from user - number of rooms and if its 5 rooms then ask weather its a duplex or regular
- System.out.println("Please enter the number of Rooms you wish? ");
- NumOfRooms = s.nextInt();
- System.out.println("Please enter the number of Days you wish? ");
- NumofDays = s.nextInt();
- //if number of rooms < 5 then check if its 3 bedrooms price = $120 else its 4 bedrooms price = $150
- switch(NumOfRooms)
- {
- case 3:
- System.out.println("Total cost is "+NumofDays*120);
- break;
- case 4:
- System.out.println("Total cost is "+NumofDays*150);
- break;
- case 5:
- System.out.println("Would like Regular Rooms Yes or Duplex No? Y or N");
- Duplex = s.next().charAt(0);
- if(Duplex == 'Y' || Duplex == 'y')
- {
- IsDuplex = true;
- }
- if(IsDuplex)
- {
- System.out.println("Total cost is "+NumofDays*200);
- }
- else
- {
- System.out.println("your cost is "+NumofDays*180);
- }
- break;
- }
- }
- }
- package test;
- import java.util.Scanner;
- public class Exercise2 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner s = new Scanner(System.in);
- // Define Variables
- double CostSale1;
- double CostSale2;
- double TotalPaid;
- int NumOfItems;
- // Input from User TotalPaid and number of Articles he/she wishes to purchase
- System.out.println("Enter the total cost of your Purchase! ");
- TotalPaid = s.nextDouble();
- System.out.println("Enter the total number of Articles in your Purchase! ");
- NumOfItems = s.nextInt();
- // Calculate cost going by Sale price 1 and Sale price 2 depend on Articles bought
- if(NumOfItems < 3 && TotalPaid >=300)
- {
- TotalPaid = TotalPaid - 50;
- System.out.println("Your total cost after the sale is: $"+TotalPaid);
- System.out.println("Sorry, We must use this option - You bought Less than 3 Articles");
- }
- if(TotalPaid >= 300 && NumOfItems >=3)
- {
- CostSale1 = TotalPaid - 50;
- CostSale2 = TotalPaid * 0.8;
- //Compare After Discount of Sale1 and sale 2 and Notify user with results
- if(CostSale1 < CostSale2)
- {
- System.out.println("Your total cost after sale 1 is: $"+CostSale1);
- System.out.println("Sorry, We must use this option - You bought Less than 3 Articles");
- }
- else
- {
- System.out.println("Your total cost after sale 2 is: $"+CostSale2);
- System.out.println("We gladly used this option - You bought 3 or More Articles");
- }
- }
- }
- }
- package test;
- import java.util.Scanner;
- public class Exercise3 {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner s = new Scanner(System.in);
- double FinalGrade;
- double TempGrade;
- int MidGrade;
- int HomeWorkGr;
- int ClassAttend;
- int ExamGrade;
- //Get from the user the percentage of their attendance in class
- System.out.println("Enter the Percentage of Student Attendence! ");
- ClassAttend = s.nextInt();
- if(ClassAttend < 80)
- {
- FinalGrade = 0;
- System.out.println("Your final Grade is :"+FinalGrade);
- }
- else
- {
- //Input Student Test Grade if its = 60 or greater than 60 input Mid grade and Home Work grade
- System.out.println("Enter Student Test Grade! ");
- ExamGrade = s.nextInt();
- if (ExamGrade >= 60)
- {
- System.out.println("Enter Student Mid Grade! ");
- MidGrade = s.nextInt();
- System.out.println("Enter Student Home Work Grade! ");
- HomeWorkGr = s.nextInt();
- if(MidGrade > ExamGrade)
- {
- TempGrade =(0.8 * ExamGrade) + (0.2 * MidGrade);
- }
- else
- {
- TempGrade = ExamGrade;
- }
- FinalGrade = (0.1 * HomeWorkGr)+(0.9 * TempGrade);
- }
- else
- {
- FinalGrade = ExamGrade;
- }
- }
- System.out.println(" Your Final Grade is: "+FinalGrade);
- }
- }package test;
- import java.util.Scanner;
- public class Exercise4 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner s = new Scanner(System.in);
- double Salary;
- double IncomeTax;
- int NumKids;
- double TaxReturn;
- boolean Adult=false;
- char isAdult;
- boolean LocationGolibar = false;
- char Liveby;
- //Get from the user Salaryand the number of Kids and if they live next to Grandparents
- System.out.println("Enter your Income! ");
- Salary = s.nextDouble();
- System.out.println("Enter the number of your kids! ");
- NumKids = s.nextInt();
- // To figure out the Income tax rate
- if (Salary < 5000)
- {
- IncomeTax = 0;
- }
- else if (Salary >= 5000 && Salary <= 10000)
- {
- IncomeTax = 0.1 * Salary;
- }
- else if( Salary >= 10000 && Salary <= 15000)
- {
- IncomeTax = 0.35 * Salary;
- }
- else
- {
- IncomeTax = .5 * Salary;
- }
- // to figure out if elgible for Discount and in what percentage of Discount
- System.out.println("Do you live close to your Gilibart! Y for yes or N for NO");
- Liveby = s.next().charAt(0);
- if(Liveby == 'y' || Liveby == 'Y')
- {
- LocationGolibar = true;
- }
- System.out.println("Are you an Adult over 18 years Old! Y for yes or N for NO");
- isAdult = s.next().charAt(0);
- if(isAdult == 'y' || isAdult == 'Y')
- {
- Adult = true;
- }
- if(Adult)
- {
- if(LocationGolibar && Salary < 10000 )
- {
- IncomeTax = IncomeTax - 400;
- }
- if (NumKids > 3)
- {
- IncomeTax = IncomeTax - 900;
- }
- else
- {
- IncomeTax = IncomeTax - (NumKids * 300);
- }
- }
- else
- {
- IncomeTax = IncomeTax - (IncomeTax * 0.5);
- }
- System.out.println( "Your Income Tax is :"+IncomeTax);
- }
- }package test;
- import java.util.Scanner;
- public class Exercise5 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner s = new Scanner(System.in);
- double XTestScore;
- double NHomeWork;
- double YHomeworkAvg;
- // get the input from student
- System.out.println("Enter the Test Score! ");
- XTestScore = s.nextInt();
- System.out.println("Enter the number of home Work you Submited! ");
- NHomeWork = s.nextInt();
- System.out.println("Enter your Averge Grade for Homeworks! ");
- YHomeworkAvg = s.nextDouble();
- // case Student's number of home works is less than or equal 4 - test
- // score is final
- if (NHomeWork <= 4 )
- {
- System.out.println("Your Total Score is :" + XTestScore);
- }
- // case2 Student's number of home works is less than or equal 7 - Check
- // test score >= 60
- // and test score < 60 calculate score by getting Percentage on home
- // works and score
- else if ((NHomeWork > 4 && NHomeWork < 8 )&& (XTestScore >= 60))
- {
- XTestScore = 0.8 * XTestScore + 0.2 * YHomeworkAvg;
- System.out.println("Your Total Score is :" + XTestScore);
- } else if ((NHomeWork > 4 && NHomeWork < 8 ) && (XTestScore < 60)) {
- XTestScore = 0.9 * XTestScore + 0.1 * YHomeworkAvg;
- System.out.println("Your Total Score is :" + XTestScore);
- }
- // case Student's number of home works is bigger than or equal 8 - Check
- // test score >= 60
- // and test score < 60 calculate score by getting Percentage on home
- // works and score
- if (NHomeWork >= 8 && XTestScore >= 60)
- {
- XTestScore = 0.7 * XTestScore + 0.3 * YHomeworkAvg;
- System.out.println("Your Total Score is :" + XTestScore);
- } else
- if (NHomeWork >= 8 && XTestScore < 60)
- {
- XTestScore = 0.6 * XTestScore + 0.4 * YHomeworkAvg;
- System.out.println("Your Total Score is :" + XTestScore);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement