All pastes #192754 Raw Edit

pseudocode for lab 5

public text v1 · immutable
·published 2006-10-06 06:13 UTC
rendered paste body
#include <stdio.h>

/* et cetera */

main()
{
int choice declare_this

 do {  /*  loop until 0 is selected from menu() */
    menu() /* call menu to get choice */
 
     switch
      case 1 call add()
      case 2 /* implemented later */
      case 3 /* implemented later */
      case 4 /* implemented later */
      case 5 /* exit program */

  } while menu(choice) != 0
}

menu()
{
  display the menu
  prompt for choice and return it to main()
}

add()
{
  do { /* loop until continue_N is pressed */

    all of lab4 goes here

    getint() /* to get product number */
    getint() /* to get product type */
    getint() /* to get quantity */

    getreal() /* to get cost */
    getreal() /* to get price */

    show() /* to display final values */

  } while user wants to continue
}

getint()
{
  receive item to prompt for and min/max range
  return appropriate int if valid
  display error msg if invalid
}

getreal()
{
  receive item to prompt for and min/max range
  return appropriate double if valid
  display error message if invalid
}

total()
{
  receive two arguments (quantity and cost OR quantity and price)
  return total
}

show()
{
  receive 4 args: product_number, quantity, cost, and price
  total() /* to get total cost */
  total() /* to get total price */

  display everything (as in lab 2)
  return nothing
}