Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. 3PRB – Session 7 Revision Activities
  2. Subject Review / Test Revision / Practice Questions / Workshop
  3.  
  4. The test will not include program specifications, but you will be required to write pseudocode as a comment in your C# code.
  5. The test will cover sequence, selection and iteration structures.
  6. The test will not include arrays.
  7. The test will not include files.
  8.  
  9. Assessment Exercise 4 due this session
  10.  
  11.  
  12. Revision Questions
  13. Write the pseudocode and C# code for each of the problems below:
  14.  
  15. 1.Write a program to input one integer number and output the number doubled (multiply by 2).
  16.  
  17. 2.Write a program that inputs 3 doubles from the keyboard and outputs them to the screen in the reverse order. Note: the program code must actually swap the values stored in the variables.
  18.  
  19. 3.Write a program to input 3 integers and a choice of “H” or “L” where “H” displays the highest of the 3 numbers, and “L” display the lowest number. Display on screen the highest number or the lowest number.
  20.  
  21. 4.Using a nested-if structure, write a program to output the cost of a cinema ticket. The user is to enter the ticket type “S” for student, “C” for child, “N” for normal or ‘G’ for gold class. The cost of the tickets are C $10, S $11.50, N $15, G $30.50, set constants for these.
  22. Also write your solution using a switch structure.
  23.  
  24. 5.A TV salesperson is paid a wage of $2,000 per month plus $100 for every TV that they sell. Write a program that inputs and validates the number of TVs’ sold (must be greater than 0) by the salesperson in one year. The program is to calculate and output the annual salary of the salesperson.
  25. For example, if 300 TVs sold in one year, the annual salary will be $54,000
  26. (12 x 2000 + 300 x 100 = 54000).
  27.  
  28. 6.Write a program to convert miles to kilometres. Input the number of miles and output the kilometres. (kms = 1.609 * miles).
  29.  
  30. 7.Extend the above program so that it may be used by athletes competing in international marathons and long distance events. The user is to be able to enter the number of miles of the event and the program is to display a table of miles, and the calculated kilometre equivalent, for all miles between 1 and the number of event miles.
  31. (Practice writing C# loops by solving the above problem using the 3 different types of loops: While: Do While; For (i.e. write three separate solution algorithms to solve the above problem).
  32.  
  33. 8.Write a program that will calculate the average age of all the members of a family. The program is to firstly ask how many members there are in the family, and then request the age of each member. Output the average age of the family.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement