totalMFOver30 pFemaleOver30 pMaleOver30 survey is done for

Totalmfover30 pfemaleover30 pmaleover30 survey is

This preview shows page 3 - 4 out of 4 pages.

totalMFOver30 = pFemaleOver30 + pMaleOver30; System.out.println("This survey is done for Show: "+channelID); System.out.println("The total number of people surveyed = "+noOfPpl); System.out.println("The number of people who watch the show regularly = "+pplWatchReg); System.out.println("The percentage of those who watch the show regularly = "+calPercent(pplWatchReg,noOfPpl)); System.out.println("------------------------------------------------------------ --------------"); System.out.println("Gender\t\t%Under 30\t\t%30 or Over\t\t%Total"); System.out.println("------------------------------------------------------------ --------------"); System.out.println("Female\t\t "+pFemaleUnder30+"\t\t\t "+pFemaleOver30+"\t\t\t "+(pFemaleUnder30+pFemaleOver30)); System.out.println("Male\t\t "+pMaleUnder30+"\t\t\t "+pMaleOver30+"\t\t\t "+(pMaleUnder30+pMaleOver30)); System.out.println("------------------------------------------------------------ --------------"); System.out.println("Total\t\t "+(totalMFUnder30)+"\t\t\t "+ (totalMFOver30) +"\t\t\t "+(totalMFUnder30+totalMFOver30)); System.out.println("Do you wish to enter for another show (Y/N):"); enterMoreDetails = kb.next().charAt(0); enterMoreDetails = Character.toUpperCase(enterMoreDetails); while(!checkYesNo(enterMoreDetails)) { System.out.println("Invalid text entered"); System.out.println("Do you wish to enter for another show (Y/N):"); enterMoreDetails = kb.next().charAt(enterMoreDetails); enterMoreDetails = Character.toUpperCase(enterMoreDetails); } if(enterMoreDetails=='N') //Validates user wish to continue if not end loop { break; } noOfPpl=0; //Resets all value to 0 pplWatchReg=0; maleUnder30=0; maleOver30=0; femaleUnder30=0; femaleOver30=0; //Need to validate number entered not string } } public static String studentInfo() //method containing student info { String studentInfo="Name: Tan Kok Hao Antonia \nStudent Number: 33489037 \nMode of enrollment: External \nTutor name: Chong Siew Cheong" + "\nTutorial attendance day: Wednesday 14:15\n"; return studentInfo;
Image of page 3
} public static boolean checkAge(int ageInput) //method to validate user age input { return ageInput>=1 && ageInput<=110; } public static boolean checkGender(char genderInput) //method to validate gender input { return genderInput=='M'||genderInput=='F'; } public static boolean checkYesNo(char yOrN) //method to validate user input yes or no { return yOrN=='Y'||yOrN=='N'; } public static int calPercent(int num1, int total) //method to calculate percentage of number referenced { if(total==0) //number cannot be divided by 0 so this sets number to 1 if obatained number is 0 { total+=1; } num1 = num1*100/total; return num1; } }
Image of page 4

You've reached the end of your free preview.

Want to read all 4 pages?

  • One '14
  • Grammatical number, Grammatical conjugation, Enter key, char enterMoreDetails, char genderInput, char watchRegInput

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes