Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Exercise 1
- import java.util.Scanner;
- public class Exe1 {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner s = new Scanner(System.in);
- // Define variables
- boolean IsDuplex = false;
- int NumOfRooms;
- double Price;
- 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();
- //if number of rooms < 5 then check if its 3 bedrooms price = $120 else its 4 bedrooms price = $150
- if (NumOfRooms < 5)
- {
- if(NumOfRooms == 4)
- {
- Price = 150 ;
- }
- else
- {
- Price = 120;
- }
- }
- else
- {
- // it is 5 bedrooms check to see if User wants a Douplex if Yes set IsDuplex to true and set the price 200 else 180 not Duplex
- System.out.println("Please, type t if its Duplex or F if its not ");
- Duplex =s.next().charAt(0);
- if(Duplex == 't' || Duplex == 'T')
- {
- IsDuplex = true;
- Price = 200;
- }
- else
- {
- Price = 180;
- }
- }
- System.out.println(" Your Total cost for "+NumOfRooms+ " BedRooms IS: "+Price);
- }
- }
- //Exercise 2
- import java.util.Scanner;
- public class Exes2 {
- 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
- CostSale1 = TotalPaid - (int)(TotalPaid / 300)* 50;
- if(NumOfItems == 3 || NumOfItems > 3)
- {
- CostSale2 = TotalPaid * 0.80 ;
- //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);
- }
- else
- {
- System.out.println("Your total cost after sale 2 is: $"+CostSale2);
- }
- }
- System.out.println("Your total cost after sale 1 is: $"+CostSale1);
- }
- }
- //Exercise 3
- import java.util.Scanner;
- public class Exes3 {
- /**
- * @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("The 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 || 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*middleExamGrade
- TempGrade =(0.8 * ExamGrade) + (0.2 * MidGrade);
- System.out.println("Mid Grade > Exam Grade - The final Grade is :"+TempGrade);
- }
- else
- {// tempGrade = examGrade and final grade = 0.1*hwGrade + 0.9*tempGrade
- TempGrade = ExamGrade;
- FinalGrade = (0.1 * HomeWorkGr)+(0.9 * TempGrade);
- System.out.println("10% of Homework + 90% Exam Grade Equals The final Grade is :"+FinalGrade);
- }
- }
- System.out.println("The Test Grade Equals the Final Grade :"+ExamGrade);
- }
- }
- }
- //Exercise 4
- import java.util.Scanner;
- public class Exes4 {
- /**
- * @param args
- */
- 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;
- Salary = Salary;
- }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 Parents! 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( "You have to pay :"+IncomeTax);
- }
- System.out.println( "You have to pay or Get :"+IncomeTax);
- }
- }
- //Exercise 5
- import java.util.Scanner;
- public class Exes5 {
- /**
- * @param args
- */
- 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();
- // 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
- if ((NHomeWork > 4 && NHomeWork < 8 )&& (XTestScore >= 60)) {
- YHomeworkAvg = 0.8 * XTestScore + 0.2 * NHomeWork;
- XTestScore = ( XTestScore + YHomeworkAvg) / 2;
- System.out.println("Your Total Score is :" + XTestScore);
- } else if ((NHomeWork > 4 && NHomeWork < 8 ) && (XTestScore < 60)) {
- YHomeworkAvg = 0.9 * XTestScore + 0.1 * NHomeWork;
- XTestScore = ( XTestScore + YHomeworkAvg) / 2;
- 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)
- {
- YHomeworkAvg = 0.7 * XTestScore + 0.3 * NHomeWork;
- XTestScore = ( XTestScore + YHomeworkAvg) / 2;
- System.out.println("Your Total Score is :" + XTestScore);
- } else
- if (NHomeWork >= 8 && XTestScore < 60)
- {
- YHomeworkAvg = 0.6 * XTestScore + 0.4 * NHomeWork;
- XTestScore = ( XTestScore + YHomeworkAvg) / 2;
- System.out.println("Your Total Score is :" + XTestScore);
- }
- }
- }
Add Comment
Please, Sign In to add comment