Interview Question in Visual Studio 2005
Interview Question :: Having problems sorting out my code could someone help me with this program please it is vb.net |
here is the problems, what i tried is below it, having trouble putting this code togeather could somone help me with it and mainly getting the variables right and using the loops correctly.
this is using visual studios 2005
Name this project Marks.
Create a console application for the following problem.
• Place a title on the screen “Marks Program by Your Name”
• Prompt the user: “Do you want to calculate average marks (Y/N)?”
• If the user enters a Y/y, the program will prompt “How many marks (3-6)?” and read an integer between 3 and 6. Use a do while pre-test loop to get a valid number, displaying an invalid message if necessary. Use constants for 3 and 6. Once you get a valid number, read in that many marks (single) from the user and find the average. Marks entered must be between 0.0 and 100.0. Keep reading marks until they are in that range. Use a for loop to read in the marks. Display the following on the screen: “n marks entered and the average is nn.nn”, where n represents the number the user entered and nn.nn represents the average.
• If the user enters an N/n, the program will end.
• If the users enters anything besides a Y/y or N/n, display invalid and re-prompt “Do you want to calculate average marks (Y/N)?”
• Hand in pseudocode by Tuesday, Nov. 4 at 8:30 am. (5 marks)
• Pseudocode must be typed in Word with your name on it.
Your test cases are as follows with messages:
Marks Program by Your Name
Do you want to calculate average marks (Y/N)? X
Invalid option, please try again
Do you want to calculate average marks (Y/N)? y
How many marks? (3-6): 14
Invalid number of marks, choose (3-6): 4
Enter mark 1: -17
Error - marks must be between 0 - 100: 120
Error - marks must be between 0 - 100: 67.5
Enter mark 2: 73.5
Enter mark 3: 76.5
Enter mark 4: 96.5
4 marks entered and the average is 78.5
Do you want to calculate average marks (Y/N)? Y
How many marks? (3-6): 3
Enter mark 1: 77
Enter mark 2: 84
Enter mark 3: 63
3 marks entered and the average is 74.66666
Do you want to calculate average marks (Y/N)? N
Press any key to continue . . .
Imports system.console
Dim num as integer
Dim counter as integer
Dim Marks as Single
Dim Grade as single
Dim char as string=''Y,y" , N,n''
Const MIN as integer= 3
Const MAX as integer = 6
Const grademin as single = 0.0
Const grademax as single = 100.0
Writeline(“ Marks program by Brian Murphy”)
Readline()
Writeline(“ Do you want to calculate average marks (Y/N)?
Readline= char
If char = "Y,y" Then
‘ prompt user to enter number of marks
For counter = 3 to 6
‘prompt user for a valid number
Write= (“ Enter a number “ & counter & “ of 6:”)
Num= readline()
Do while counter >3 or <6
'tell user number is invalid . Prompt for number again
Loop while counter <3 or >6
Write (“Invalid number. Enter another number")
Else if char="N,n" Then
Writeline("
Loop
Next
For
|
|
|
|

Loading ...