Write a program in QBasic to count number of male and female students in class. Print out the number of males, number of females and total number of students.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> */ <br /><br />DIM nTotal AS Integer, nMale AS INTEGER, nFemale AS INTEGER <br />DIM choice AS Integer, sex AS INTEGER, female AS INTEGER<br /><br />nTotal = 0<br />nMale = 0<br />nFemale = 0<br /><br />PRINT ""<br />PRINT "THIS PROGRAM COUNTS AND PRINTS THE NUMBER OF MALES AND FEMALES IN A CLASS"<br />PRINT "-------------------------------------------------------------------------"<br />PRINT ""<br /><br />INPUT "DO you want to start (-1 to quit)"; choice<br /><br />DO WHILE choice <> -1<br /> INPUT "Is student a male (1 = yes, 2 = no)"; sex<br /> IF sex = 1 THEN<br /> nMale = nMale + 1<br /> ELSE<br /> nFemale = nFemale + 1<br /> ENDIF<br /> <br /> nTotal = nTotal + 1<br /> <br /> INPUT "DO you want to continue (-1 to quit)"; choice<br />LOOP<br /><br />PRINT "" <br />PRINT "The total number of MALE students = "; nMale<br />PRINT "The total number of FEMALE students = "; nFemale<br />PRINT "The total number of students = "; nTotal<br /> |