need help in my assignment
[ Follow Ups ] [ Post Followup ] [ Message Board for Team 27297 ]

Posted by cammy l. on October 03, 19102 at 16:01:41:

hello everyone..
i'm new at using pascal..and i have assignment due tonight.. i already did the first part of the programming, but the second one that i have to modify from the first one..don't understand..please help me..

assignment1

Program Fall2002Assignment1;

Var a,b:integer;
c:real;
ans:char;

Begin
Repeat
Writeln ('This program calculates the hypotenuse of a right triangle.');

Writeln ('Enter the length of a');
Readln (a);
While a<=0 do
Begin
Writeln (a,' is not a positive integer greater than 0. Enter a positive integer.');
readln (a);
End;

Writeln ('Enter the length of b');
Readln (b);
While b<=0 do
Begin
Writeln (b,' is not a positive integer greater than 0. Enter a positive integer.');
readln (b);
End;

c:=sqrt(sqr(a)+sqr(b));

Writeln ('The hypotenuse of a right triangle with a leg of ',a,' and a leg of ',b,' is',c:3:0);

Writeln ('Would you like to calculate another hypotenuse? Y or N');
Readln (ans);

Until upcase(ans) = 'N';

Writeln ('The program has ended. Press Enter.');

Readln;
End.

assignment2:

F02A1.pas is a sample program that meets the requirements outlined in Assignment #1 Part B. You will use this file to complete Assignment #2.

Modify the program F02A1.pas. The program must:
„Ï Be a mainline program
„Ï Use a procedure called Menu. It will
„X Accept no parameters
„X Output a menu to the screen that looks like:
************************************************************** MENU **************************************************************
K - Calculate the hypotenuse, use the keyboard
F - Calculate multiple hypotenuse, use a file
X - Exit
**************************************************************
„X Read the user¡¦s choice and
„Ï Call HypKeyboard if K is selected
„Ï Call HypFile if F is selected
„Ï End the program if X is selected
„Ï Use a procedure called HypKeyboard. It will
„X Accept no parameters
„X Have all the same variables as the program in F02A1.pas (Remove the variables from the VAR section)
„X Include all lines of code within the Repeat Until Loop
„X Call the procedure Negative if an integer entered is less than or equal to 0.
„X Call the function CalcHyp to calculate the hypotenuse.
„Ï If a negative integer is entered through the keyboard, the program must use a procedure called Negative to
„X Accept the integer entered
„X Output the error message ¡¥X is not a positive integer greater than 0. Enter a positive integer.¡¦
„X Read the newly entered integer
„X Send the newly entered integer back to the main program
„Ï Use a function called CalcHyp to
„X Accept the values of the 2 legs of the triangle
„X Calculate the hypotenuse
„Ï Use a procedure called HypFile. It will
„X Accept no parameters
„X Output a header that states, ¡§This program reads from a file and calculates the hypotenuse of a right triangle.¡¨
„X Read the values of a and b from a file
„X Call the function CalcHyp to calculate the hypotenuse
„X For each line of data in the file, output ¡§The hypotenuse of a right triangle with a leg of X and a leg of Y is Z¡¨. Where X is equal to the length of side a, Y is equal to the length of side b, and Z is equal to the hypotenuse or side c.
„X If the file was empty, output the message, ¡§The file was empty.¡¨ else it will output the message, ¡§There were X lines of data in the file.¡¨
„X Assume that all values in the file are positive
„X There are an unknown number of data lines in the file
„Ï The program will no longer state that the program has ended.




Follow Ups:



Post a Followup

Name:
E-Mail:
Subject:
Comments:
Optional Link URL:
Link Title:
Optional Image URL:

Sorry, we are no longer accepting entries to this message board.


[ Follow Ups ] [ Post Followup ] [ Message Board for Team 27297 ]