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 ATLProg Your Own Question

ATLProg
ATLProg, Software Engineer
Category: Homework
Satisfied Customers: 9151
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
44910485
Type Your Homework Question Here...
ATLProg is online now
A new question is answered every 9 seconds

You may use a Case statement or an If/Then constructDesign

This answer was rated:

You may use a Case statement or an If/Then construct

Design an algorithm that will read two numbers and an integer code (1 – 4) from the user.
1- add
2- subtract (be sure the difference is positive)
3- multiply
4- divide (Do not find the quotient if the second number is XXXXX If the second number is XXXXX display an error message)
Any integer code number higher than 4 will also result in an error message (assume they will not input a code lower than 1).

Output: Display the selected code and the problem in equation form.

Ex: Please input the first value: 2
Please input the second value: 4
(Show the menu)
Please input a code from 1 to 4: 1

Output:
Selected code: 1
2 + 4 = 6

Please input the first value: 2
Please input the second value: 4
(Show the menu)
Please input a code from 1 to 4: 2

Output:
Selected code: 2
4 - 2 = 2

Use a For/Next loop to run the program 6 times. See page 7 of the VB notes.

Test data: values: code:
2, 4 5 Display an error message (“Please select 1-4 only”)
2, 4 1
2, 4 2
2, 4 3
2, 0 4 Display an error message (“Cannot divide by 0”)
2, 4 4

Run the program, copy the output to the bottom of the code, print out and call me over to check. Be sure to copy the program to your “G” drive location, and to your flash drive.

Be sure to use remarks for documentation; use proper spacing in code and on the screen.

Note: use the data type of Decimal for the answer so that the division problem will show a decimal answer. You may do the math and display the answer in the same block of code.

ATLPROG :

Hello i can assist you

ATLPROG :

By when you need this done?

Customer:

real soon

Customer:

before 2

ATLPROG :

Can you paste the code that you have so far

Customer:

yea

Customer:

Option Strict Off
Option Explicit On


Module Module1


Sub Main()


'Declare all variables
Dim num_1
Dim num_2
Dim int_code
Dim result
Dim Valid As Boolean


Valid = True


'Prompt and Get the input
Console.Write("Please input the first value: ")
num_1 = Console.ReadLine()


Console.Write("Please input the second value: ")
num_2 = Console.ReadLine()


Console.Write("Please input a code from 1 to 4: ")
int_code = Console.ReadLine()


'Use select case to figure out int_code


Select int_code
Case 1
result = num_1 + num_2
Case 2
result = num_1 - num_2
Case 3
result = num_1 * num_2
Case 4
result = num_1 / num_2
Case Else
Console.WriteLine("Invalid Code Entry!")
Console.ReadLine()
Valid = False
End Select


'Perform the calculation
If Valid Then


'Display output
Console.WriteLine() 'to get a blank line
Console.WriteLine("Selected code: " & int_code)
int_code = Console.ReadLine()


End If


End Sub


End Module

ATLPROG :

and what problem you are facing?

Customer:

well im facing multiple problems, i dont know how to display the out liek this

Customer:

Output:
Selected code: 2
4 - 2 = 2

Customer:

obviously if the selected code is 2

ATLPROG :

ok

ATLPROG :

let me see

Customer:

Design an algorithm that will read two numbers and an integer code (1 – 4) from the user.
1- add
2- subtract (be sure the difference is positive)
3- multiply
4- divide (Do not find the quotient if the second number is XXXXX If the second number is XXXXX display an error message)
Any integer code number higher than 4 will also result in an error message (assume they will not input a code lower than 1).

Customer:

also the substract and divide

Customer:

on the divide it says to display an error if the second number is XXXXX

Customer:

im doing this all in visual studio 2010 btw

ATLPROG :

yes

Customer:

also this part

Customer:

Use a For/Next loop to run the program 6 times. See page 7 of the VB notes.

Test data: values: code:
2, 4 5 Display an error message (“Please select 1-4 only”)
2, 4 1
2, 4 2
2, 4 3
2, 0 4 Display an error message (“Cannot divide by 0”)
2, 4 4

Customer:

where i have to run a loop on the program 6 times

ATLPROG :

i will be done soon

Customer:

okay thank you very much

Customer:

im going to step away from the computer for 5 minutes

Customer:

hey you there?

THIS ANSWER IS LOCKED!

You need to spend $3 to view this post. Add Funds to your account and buy credits.
ATLProg and other Homework Specialists are ready to help you