Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- static Scanner in = new Scanner(System.in);
- public static void main(String[] args) {
- menuMethod();
- }
- private static void menuMethod() {
- int iMenu;
- do {
- System.out.println("Enter the question number you wish to see. and press 6 to exit!");
- iMenu = in.nextInt();
- switch (iMenu) {
- case 1:tar1();
- break;
- case 2:tar2();
- break;
- case 3:tar3();
- break;
- case 4:tar4();
- break;
- case 5:tar5();
- break;
- case 6:return;
- default:System.err.println("You need to enter a number from 1-5!");
- break;
- }
- }while(iMenu != 6);
- }
- public static void tar1(){
- int iDay;
- System.out.println("Enter a number from 1-7 to know which day it is");
- iDay = in.nextInt();
- //finds what day of the week it is
- switch(iDay){
- case 1:System.out.println("Sunday");
- break;
- case 2:System.out.println("Monday");
- break;
- case 3:System.out.println("Tuesday");
- break;
- case 4:System.out.println("Wednesday");
- break;
- case 5:System.out.println("Thursday");
- break;
- case 6:System.out.println("Friday");
- break;
- case 7:System.out.println("Saturday");
- break;
- default:System.err.println("You need to enter a number from 1-7");
- }
- }
- public static void tar2(){
- int iNum;
- System.out.println("Enter a number from 1-10");
- iNum = in.nextInt();
- //finds if number is small medium or large
- switch(iNum){
- case 1:
- case 2:
- case 3:System.out.println("You entered a Small number");
- break;
- case 4:
- case 5:
- case 6:
- case 7:System.out.println("You entered a Medium number");
- break;
- case 8:
- case 9:
- case 10:System.out.println("You entered a Large number");
- break;
- default:System.err.println("You need to enter a number from 1-10");
- }
- }
- public static void tar3(){
- char cLetter;
- System.out.println("הכנס את האות הראשונה של שם המשפחה של ילדכם");
- cLetter = in.next().charAt(0);
- //finds what day the child is Summoned to school by his/her last name
- switch(cLetter){
- case 'א':
- case 'ב':
- case 'ג':
- case 'ד':
- case 'ה':
- case 'ו':
- case 'ז':
- case 'ח':
- case 'ט':
- case 'י':System.out.println("אתם מוזמנים ליום ראשון");
- break;
- case 'כ':
- case 'ל':
- case 'ק':
- case 'ר':
- case 'ש':
- case 'ת':System.out.println("אתם מוזמנים ליום שני");
- break;
- default:System.out.println("אתם מוזמנים ליום שלישי");
- }
- }
- public static void tar4(){
- int iItem,iItemAmount,iItemPrice;
- System.out.println("Enter the item number you wish to buy (1-8)");
- iItem = in.nextInt();
- System.out.println("how many would you you like to purchase?");
- iItemAmount = in.nextInt();
- System.out.println("What is the price of a single item?");
- iItemPrice = in.nextInt();
- //finds out if he needs a discount or not then calculates how much discount he deserves
- if (iItemAmount > 35)
- {
- switch (iItem) {
- case 1:
- case 4:
- case 6:System.out.println("You need to pay " + (iItemPrice*0.95)*iItemAmount + " shekels");
- break;
- case 2:
- case 5:System.out.println("You need to pay " + (iItemPrice*0.9)*iItemAmount + " shekels");
- break;
- case 3:
- case 7:
- case 8:System.out.println("You need to pay " + (iItemPrice*0.8)*iItemAmount + " shekels");
- break;
- default:
- System.err.println("You were supposed to enter a number from 1-8");
- break;
- }
- }
- else if(iItem > 8 || iItem < 1)
- {
- System.err.println("You were supposed to enter a number from 1-8");
- }
- else if (iItemAmount <= 35)
- {
- System.out.println("You need to pay " + (iItemAmount*iItemPrice) + " shekels");
- }
- }
- public static void tar5(){
- int iEmployeeNumber,iSalary;
- System.out.println("Enter your employee number (1-4)");
- iEmployeeNumber = in.nextInt();
- System.out.println("Enter your salary");
- iSalary = in.nextInt();
- //checks what the employee number is and finds out how much taxes the employee needs to pay based on his salary and employee number
- switch (iEmployeeNumber) {
- case 1:
- case 2:
- if (iSalary < 3500)
- {
- System.out.println("You need to pay " + (iSalary * 0.005) + " shekels in taxes");
- System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.005) + " shekels");
- }
- else if (iSalary >= 3500)
- {
- System.out.println("You need to pay " + (iSalary * 0.0075) + " shekels in taxes");
- System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.0075) + " shekels");
- }
- break;
- case 3:
- if (iSalary < 5000)
- {
- System.out.println("You need to pay " + (iSalary * 0.01) + " shekels in taxes");
- System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.01) + " shekels");
- }
- else if (iSalary >= 5000)
- {
- System.out.println("You need to pay " + (iSalary * 0.025) + " shekels in taxes");
- System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.025) + " shekels");
- }
- break;
- case 4:
- if (iSalary < 7500)
- {
- System.out.println("You need to pay " + (iSalary * 0.015) + " shekels in taxes");
- System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.015) + " shekels");
- }
- else if (iSalary >= 7500)
- {
- System.out.println("You need to pay " + (iSalary * 0.02) + " shekels in taxes");
- System.out.println("Your salary after TAX is " + (iSalary-iSalary * 0.02) + " shekels");
- }
- default:
- System.err.println("you were supposed to enter an employee number from 1-4");
- break;
- }
- }
- public static void tar6(){
- int iDay,iHourIncome,iWorkHours;
- System.out.println("Enter the number representing the day of the week");
- iDay = in.nextInt();
- System.out.println("Enter your hourly income");
- iHourIncome = in.nextInt();
- System.out.println("Enter how many hours you worked");
- iWorkHours = in.nextInt();
- //finds if employee deserves a discount based on his work hours and prints out his salary to screen
- switch (iDay) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- if (iWorkHours > 8)
- {
- System.out.println("your salary is " + (8*iHourIncome + (iWorkHours-8)*1.25*iHourIncome) + " shekels");
- }
- else if (iWorkHours <= 8)
- {
- System.out.println("your salary is " + (iWorkHours*iHourIncome) + " shekels");
- }
- break;
- case 6:
- if (iWorkHours > 5)
- {
- System.out.println("your salary is " + (5*iHourIncome + (iWorkHours-5)*2.00*iHourIncome) + " shekels");
- }
- else if (iWorkHours <= 5)
- {
- System.out.println("your salary is " + (iWorkHours*iHourIncome) + " shekels");
- }
- break;
- case 7:
- if (iWorkHours > 5)
- {
- System.out.println("your salary is " + (5*iHourIncome + (iWorkHours-5)*3*iHourIncome) + " shekels");
- }
- else if (iWorkHours <= 5)
- {
- System.out.println("your salary is " + (iWorkHours*iHourIncome) + " shekels");
- }
- break;
- default:
- System.err.println("You need enter a number from 1-7");
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement