CPSC 120 LAB 2 Back to Lab index page

Lab must be completed and reviewed by Peer Instructor Seth Peery no later than Wed, Sept 5 during lab class.

You are to enter a program that will read three data items into variables x, y, and z and then finds and displays their product and sum. Variables x, y, and z are integer values. You should prompt the user for the three numbers and print the numbers and their product and sum. You should name the file that holds this program, sumproduct.adb.

When you complete this lab you should ask it be checked by your lab peer instructor. Once checked the completion points for this lab will be recorded.

The following is a beginning for this program, however -- you'll need to add a number of statements to make it work. You should input, compile, and execute this program.

WITH Ada.Text_IO;
WITH Ada.Integer_Text_IO;

PROCEDURE sumproduct IS
---------------------------------------------------------------
-- This program reads three data items and calculates their product and sum.
-- Program is written by YOUR NAME, 9/1/99
---------------------------------------------------------------

x : integer;
y : integer;
z : integer;
sum : integer;
product : integer;

BEGIN -- sumproduct
Ada.Text_IO.Put (Item => "Enter three integer numbers, type enter after each number");
Ada.Integer_Text_IO.Get (Item => x);

- -((((( you'll need to add more Get statements here for y and z)))))

sum := x + y + z;
product := - -????????????????

Ada.Text_IO.Put(Item => " The three numbers input are:");
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(Item => "x =");
Ada.Integer_Text_IO.Put(Item => x);
Ada.Text_IO.New_Line;

- -(((((More Put statements and New_Line needed here for y & z)))))

- -((((( More Put statements needed here to display the product and sum of the numbers )))))

END sumproduct;