Lecture-05.2

# Lecture-05.2 - Otherwise, print a line showing the number...

This preview shows page 1. Sign up to view the full content.

CSE 1540.03 Week 5.2 February 1, 2012 Typical Test/Exam Questions: Trace the following program fragment: integer n, m, k, j n = 0 m = 0 do k = 1, 3 do j = k, 1, -1 n = n + j end do m = m + k end do print*, n print*, m A vending machine gives change using only one dollar coins (loonies) and one cent coins (pennies). Write a program to simulate this as follows: Read the amount, in cents, as an integer. If the amount is not positive or is greater than 10 dollars, print the message Invalid amount.
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Otherwise, print a line showing the number of loonies and pennies that the machine will generate as change. Note that if either count is zero, it should not be displayed. Enter the change amount 34 34 pennies Enter the change amount 340 3 loonies and 40 pennies Enter the change amount 600 6 loonies program VendingMachine implicit none integer*4 amt print*, "Enter the change amount" read*, amt CSE 1540 Week 5.2 – February 1, 2012 page 1 of 1...
View Full Document

## This note was uploaded on 02/13/2012 for the course CSE 1540 taught by Professor Hofbauer during the Winter '12 term at York University.

Ask a homework question - tutors are online