CIS/115 CIS 115 CIS115 Visual Basic 2010 - Week 5 - Lab 5 - iLab 5
    CIS/115 CIS 115 CIS115 Visual Basic 2010 - Week 5 - Lab 5 - iLab 5 CIS/115 CIS 115 CIS115 Visual Basic 2010 - Week 5 - Lab 5 - iLab 5 CIS/115 CIS 115 CIS115 Visual Basic 2010 - Week 5 - Lab 5 - iLab 5

CIS/115 CIS 115 CIS115 Visual Basic 2010 - Week 5 - Lab 5 - iLab 5

$20.00

 

SKILL SET:  Algorithms using repetiton

Complete the FIVE problems listed below.  For each problem:

·   List the INPUTS and OUTPUTS for the problem

·   Draw a flowchart to represent the solution algorithm.

·   Show a deskcheck of the solution algorithm using the test cases indicated.  (Use LOOP DESKCHECK TEMPLATE)

·   Write out the pseudocode (make sure you use proper indentation)

·   Code in Visual Basic

 

Problem 1:  A second hand store is having a five day sale during which the price of any unsold item drops 10% each day.  The input is the original price of the item.  Validate that the price is positive.  Calculate and display the price of the item on each day, one through five.  For example, consider an item with an original price of $10.00.  On day one of the sale it costs 10% less, or $9.00.  On the second day it is 10% less than $9.00, or $8.10.  So the output would be:

 

VB Sample program output  - TEST CASE 1:

 

Enter item number: Q99

Enter original price: -10

Error - Price must be positive, please re-enter:  10

 

Five day pricing for item Q99

 

Day      Price

  1     $ 9.00

  2     $ 8.10

  3     $ 7.29

  4     $ 6.56

  5     $ 5.90

Press any key to continue

 

 

Test case 2:     Item number E33, price of 320.00

Test case 3:     Item number J22, price of 1999.00

 

Problem 2:  In this problem the user inputs an integer number of 1 or greater.  The program should calculate and display the sum of all of the integers from 1 to this number.  Use a loop to validate the input, i.e. make sure that the number input is 1 or greater before proceeding with the calculation.  (For example, if you input 4 as the number, the program should calculate the sum:  1 + 2 + 3 + 4 and display the answer as 10.) 

 

Show a desk check with the following. 

  • the number 6
  • the number 3

 

VB Sample program output – note formatting (TEST CASE 1):

 

Enter a positive integer: -4

Number must be positive.  Please re-enter: -4

Number must be positive.  Please re-enter: 4

 

The sum of the integers from 1 to 4 is 10

Press any key to continue

 

 

Test Case 2:  28

Test Case 3:  95

 

Problem 3: The admissions office of your local university wants to know how well male and female students perform in certain courses.  You will enter the student’s gender (‘m’ or ‘f’) and gpa.  Input continues until the user enters ‘x’ as the gender.  Each time a gender and gpa is entered, you will need to add it to the appropriate total so that you can calculate the average gpa for female students and the average gpa for male students.  Remember, each average will require an accumulator and a counter (separate ones for each gender).  If there are no students of a particular gender then print “No men” or “No women”.  See sample output below:

 

Test Case 1

Gender                        GPA

F                                  2.5

F                                  3.2

M                                 2.8

F                                  3.0

M                                 2.2

X

Test Case 2:

Gender                        GPA

F                                  3.3

F                                  3.5

X

 

 

VB Sample Output (Test Case 1)

 

Enter gender or x to quit: f

Enter gpa: 2.5

Enter gender or x to quit: f

Enter gpa: 3.2

Enter gender or x to quit: m

Enter gpa: 2.8

Enter gender or x to quit: f

Enter gpa: 3.0

Enter gender or x to quit: m

Enter gpa: 2.2

Enter gender or x to quit: x

Male GPA Average: 2.5

Female GPA Average: 2.9

Press any key to continue . . .

 

 

Test Case 2:  (no males entered)

Gender                        GPA

F                                  3.3

F                                  3.5

 

Problem 4:  Design a program for a utility company.  The user first inputs the total kilowatt-hours used during the month by all customers.  Then the user inputs the information for each customer:  customer number and electricity usage (in kilowatt hours) for the month.  Data ends with a customer number of -1.  Design a solution algorithm that will read this data and calculate and display the amount to be billed for the customer.  The amount billed is calculated at 11 cents for each kilowatt hour used up to 200 hours.  After the first 200 hours, the customer is charged 8 cents for each kilowatt hour used over 200 hours.  The individual usage amounts are also to be accumulated to calculate the total electricity usage.  This value should be the same as the initial number input; if not it indicates a data entry problem.  At the end of the program, compare the total electricity usage accumulated in the program with the value provided in the initial input, and print an error message if the totals are not equal, or print “Total usage verified” if the totals are equal.

 

 

Test case 1: 

Total usage 500

Customer num                                     Usage

123                                                      150

310                                                      375

-1

 

 

Test case 2: 

Total usage 1000

Customer num                                     Usage

120                                                      330

210                                                      250

300                                                      150

330                                                      270

-1

 

 

VB Sample output (Test Case 1)  (note data in bold is input from keyboard)

 

Enter total kilowatt hours used by all customers this month: 800

 

Enter customer number (0 to stop): 123

Enter electricity usage in kw hours: 100

Customer: 123   Amount owed: $11.00

 

Enter customer number (0 to stop): 234

Enter electricity usage in kw hours: 200

Customer: 234   Amount owed: $22.00

 

Enter customer number (0 to stop): 321

Enter electricity usage in kw hours: 350

Customer: 321   Amount owed: $34.00

 

Enter customer number (0 to stop): 456

Enter electricity usage in kw hours: 210

Customer: 456   Amount owed: $22.80

 

Enter customer number (0 to stop): 0

End of data

 

Total customer kilowatt hours used: 860

 

Error:  Customer totals do not match total used

Please recheck data

Press any key to continue

 

 

Test Case 2:

Total usage 1000

Customer num 120                              Usage 330

Customer num 210                              Usage 250

Customer num 300                              Usage 150

Customer num 330                              Usage 270

Customer num 0

 

This is the Project -  Visual Basic 2010 - iLab 5

Attached Files

Move over [ preview ] file name to preview content in it!

Write a review

Your Name:


Your Review: Note: HTML is not translated!

Rating: Bad           Good

Enter the code in the box below:



PURCHASE SAVE
2 Tutorials 10%
3 Tutorials 13%
4 Tutorials 16%
5 Tutorials 19%
6 Tutorials 22%
7 Tutorials 25%
8 Tutorials 28%
9 Tutorials 31%
10 Tutorials 34%
add url more

9MZQASHWN73B