• 100% Satisfaction Guarantee
lifesaver, Computer Software Engineer
Category: Programming
Satisfied Customers: 5962
Experience:  Several years of intensive programming and application development experience in various platforms.
16528259
lifesaver is online now

# I have a practice exam and I need help with exercise. See below.

I have a practice exam and I need help with exercise. See below. Thanks.

Exercise 2: Euclid's Algorithm
Using the template given below and the pseudocode for Euclid's Algorithm, write a C++ program that computes the greatest common divisor (GCD) of two numbers. Remember to maintain all the blank lines, spaces, and general alignment in the template. Then replace the areas that have been highlighted in yellow with your code. Do not change any of the other code.
Code Template for Exercise 2
/*******************************************************/
/* File: name of your file with the source code */
/* */
/* Created by: give your name */
/* Date: give the date */
/* */
/* Program to compute the GCD of two integers */
/* */
/* Inputs: (keyboard) */
/* 1. Two numbers - only positive numbers allowed */
/* */
/* Output: */
/* Print the GCD of given numbers on the screen */
/* */
/* Algorithm: Euclid's Algorithm */
/* */
/*******************************************************/
#include
using namespace std ;
int main()
{
Declare x, y, temp, remainder as Integer.
// read in the two integers
cout << endl ;
cout << "Enter the first number (positive integer) : " ;
cin >> x ;
cout << "Enter the second number (positive integer) : " ;
cin >> y ;

//echo inputs

cout << "Input numbers are: " << x << " , " << y << endl ;
Write a C++ if statement to determine if x < y.
{ // exchange values of x and y

Write three assignment statements in C++ that are
equivalent to the three statements given in the
pseudocode.
}
/* At this point we will always have x >= y */
Initialize remainder.
while ( )
{
Write the loop expression and loop body code in C++.
In C++, the expression (x % y) gives the remainder
after dividing x by y.
}
// display the result
cout << endl ;
cout << "The GCD is: " << y << endl ;
return (0); // terminate with success
}
Test Plan for Exercise 2
Test your code with the following pairs of numbers:
1 1
2 2
5 5
20 20
2 10
10 2
3 4
4 3
36 48
48 36
90 390
252 108
1024 256
23,205 1,638
Hello Bamaboy,

Customer: replied 8 years ago.
I can upload a word doc with what needs to be change highlighted in yellow. Is that ok?
That's fine..
Customer: replied 8 years ago.
Can I send the word doc. to you by email or some other way? Thanks.
Sorry exchange of personal information is against site rules .

www.wikisend.com

Browse and uplaod the word document.

Customer: replied 8 years ago.

Ok.

GOt the word document.

Customer: replied 8 years ago.
Thanks!

http://pastebin.ca/1612930

OR

http://www.mediafire.com/?dyzrjwqmy2m

http://javascript.internet.com/math-related/gcd-lcm-calculator.html

Let me know if any complications arise.

I haven't checked all the values.Just checked for 2 or 3 values.'

I am currently checking for all the values as mentioned in the word document.
Take some time and verify all the outlputs.

IF any problems let me know.

I will correct the code.
Hi,

I rechecked the program and the program gives wrong output for few cases,

Here is the perfect program.

http://pastebin.ca/1613172

Checked and it Gives correct output for all the cases.Please modify your program.

Edited by lifesaver on 10/11/2009 at 6:53 PM EST
Customer: replied 8 years ago.
I can't get this one to work.
DO you get errors?

http://www.mediafire.com/?4dmztdnmzzu

Customer: replied 8 years ago.
Thanks this one works perfect. You are my hero!
You are welcome.

I even tested it with all the test cases inside your word document.

Have a good day.
Customer: replied 8 years ago.
Customer: replied 8 years ago.
Hello, I have another exercise to complete Can you help? I will pay the same price. Thanks.
Customer: replied 8 years ago.

### Here's the exercise. Thanks.

Suppose that a float variable called score contains the overall points earned for this course. The following set of cascaded if-then-else pseudocode statements determines your final grade.

If (score >= 85) then
If (score >= 75) then
Else
If (score >= 65) then
Else
If (score >= 55) then
Else
End if // score >= 55
End if // score >= 65
End if // score >= 75
End if // score >= 85

Your assignment is to convert this pseudocode into a C++ program. Use the following template for your program and remember to maintain all the blank lines, spaces, and general alignment. Then replace the areas that have been highlighted in yellow with your code. Do not change any of the other code.

#### Code Template for Exercise 1

/****************************************************/
/* File: name of your file with the source code */ (Highlighted in yellow)
/* */
/* Created by: give your name */
/* Date: give the date */
/* */
/* Program to determine course grade */
/* */
/* Inputs: (keyboard) */
/* 1. Float - weighted total points (<= 100) */
/* */
/* Output: */
/* */
/* Algorithm: Comparisons using if-then-else */
/* */
/****************************************************/
#include <iostream>

using namespace std ;

int main()
{

Declare score and grade appropriately as variables. (Highlighted in yellow)

cout << endl ;
cout << "Enter total score (float, must be <= 100) : " ;
cin >> score ;

Write C++ if-then-else statements to determine course grade,
using the grading policy stated in the pseudocode. (Highlighted im yellow)

// display the result

cout << endl ;

return (0); // terminate with success
}

#### Test Plan for Exercise 1

Test your code with the following numbers:

85.0, 65.0001, 54.99999, -33.3, 100, 90, 150

Same methode.

Uplaodethe word template to wikiesend.
Customer: replied 8 years ago.
Ok.

GOt the file.I am working on it.
Customer: replied 8 years ago.
Thanks
Can you open this as a new question?

Mention "to lifesaver" on top of the question to direct the question to me.

ALso please note that we receive more payment from thebonus you leave.SO please consider that fact.Can't mention the reates.

SO you may open the question for a low price but the more bonus you add ,more we ge paid.

Thanks.IF you face any problem we can continue here.
Customer: replied 8 years ago.
OK