How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask R.A. McConnell Your Own Question

R.A. McConnell
R.A. McConnell, Consultant
Category: Programming
Satisfied Customers: 757
Experience:  A-Plus, MCP, 18+ years experience, LINUX admin
45119205
Type Your Programming Question Here...
R.A. McConnell is online now
A new question is answered every 9 seconds

Im in need of a Pseudo code. This may seem elementary to some

This answer was rated:

I'm in need of a Pseudo code. This may seem elementary to some but I'm having a difficult time with it because its a subject that I really have no interest in but I have to take the class due to prerequisite .

Example:

Write a program that obtains two integer numbers from the user.

It will print out the sum of those numbers.

Pseudo code:

Prompt the user to enter the first integer
Prompt the user to enter a second integer
Compute the sum of the two user inputs
Display an output prompt that explains the answer as the sum
Display the result

Hello, I'll be happy to help you with this.


Pseudo code for a project like follows:


create variables integer1, integer2, explanation, sum;
display("Please enter your first integer: ");
input integer1;
if (has_errors(integer1)) {
exit_with_error("Error. Non-integer value in first integer.");
}
newline;
display("Please enter your second integer: ");
if (has_errors(integer2)) {
exit_with_error("Error. Non-integer value in second integer.");
}
sum = integer1 + integer2;
newline;
display("The sum of the two integers is: ");
display(sum);


If you would like clarification on any of these points, more depth in my answer, or if you have additional questions with regard to this matter, please don't hesitate to ask and I'll be happy to continue to lend a hand.

R.A. McConnell and other Programming Specialists are ready to help you
Customer: replied 4 years ago.

I just noticed a few more things needed...I hope it not too late to have them added if their not already there. Thank you So much for the fast response.


 



  1. The program must have some sort of menu that allows users to make selections to do a particular calculation.

  2. It must provide five menu items that allow the user to make a calculation. There should be an additional menu item for user to exit the program. So, total of 6 menu item.

  3. Once the user selects a menu item, program should perform calculation, display the result to the user, and return to the main menu. User should be presented with main menu until they choose option to exit the program.



Do you know what the five (5) menu items (aside from the sixth, which will exit the program) should be? I can imagine the following:


  1. Enter the First Number.

  2. Enter the Second Number.

  3. Add the Numbers.

  4. Subtract the Second Number from the First.

  5. Multiply the Numbers.



But your original requirements specified adding (providing a sum) the number, so I want to make sure that a change to this is correct.
Customer: replied 4 years ago.

Thank You so much. I have been in a panic over this. Coding is not my thing, now if the assignment was write an essay or draw a picture I would be all over it. But not this. Thanks Again!!

Is the list that I provided what you want the menu to be?
Customer: replied 4 years ago.

yes

Here is the modified program with a menu. I wrote it for command line our text output (to get the formatting correct, I'll need to edit this again, so give it about five minutes, then check again):
create variables integer1, integer2, explanation, result, loopCounter, menuChoice;

create array menuItem[];

function displayMenu() {

for (loopCounter = 0; loopCounter < length(menuItem[]); loopCounter++) {

display(menuItem[x]);

}

}

menuItem[1] = "Enter the First Number" + newline;

menuItem[2] = "Enter the Second Number" + newline;

menuItem[3] = "Add the Numbers" + newline;

menuItem[4] = "Subtract the Second Number from the First" + newline; menuItem[5] = "Multiply the Numbers" + newline;

menuItem[6] = "Exit the Program" + newline; menuChoice = 0;

while (menuChoice != 6) {

displayMenu();

waitForInput menuChoice;

if (menuChoice == 1) {

display("Please enter your first integer: ");

input integer1;

if (has_errors(integer1)) {

exit_with_error("Error. Non-integer value in first integer.");

}

}

if (menuChoice == 2) {

display("Please enter your second integer: ");

if (has_errors(integer2)) {

exit_with_error("Error. Non-integer value in second integer.");

}

}

if (menuChoice == 3) {

result = integer1 + integer2;

display("The sum of the two integers is: ");

display(result + newline);

}

if (menuChoice == 4) {

result = integer1 - integer2;

display("The difference between the two integers is: ");

display(result + newline);

}

if (menuChoice == 5) {

result = integer1 * integer2;

display("The product of the two integers is: ");

display(result + newline);

}

if (menuChoice == 6) {

exitProgram;

}

else restartLoop;

}

Customer: replied 4 years ago.

Were you able to edit that code?

Yes, although the indentation didn't work quite the way I wanted. Regardless, the code as posted will work just fine.
Customer: replied 4 years ago.
Thank so very much!!! Have a great rest of your week!

Related Programming Questions