Question

Design a Do-While loop that asks the user to enter two numbers. The numbers should be...

Design a Do-While loop that asks the user to enter two numbers. The numbers
should be added and the sum displayed. The loop should ask the user whether he
or she wishes to perform the operation again. If so, the loop should repeat; otherwise
it should terminate. using visual basic

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Module VBModule

    Sub Main()
        Dim inp As Char = "y"
        Dim num1 As Integer = 0
        Dim num2 As Integer = 0
        Dim sum As Integer = 0
        Dim strnum As String = "t"
        do While inp = "y"
            Console.WriteLine("Enter a number")
            strnum = Console.ReadLine()
            num1 = CInt(strnum)
            Console.WriteLine("Enter another number")
            strnum = Console.ReadLine()
            num2 = CInt(strnum)
          
            sum = num1 + num2
            Console.WriteLine("Sum is {0}", sum)
          
            Console.WriteLine("Do you want to continue(y/n)")
            inp = Console.ReadLine()
        loop
    End Sub

End Module

Add a comment
Know the answer?
Add Answer to:
Design a Do-While loop that asks the user to enter two numbers. The numbers should be...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • write a while loop that ask the user to enter two numbers. the number should be...

    write a while loop that ask the user to enter two numbers. the number should be added and the sum displayed. the loop should ask the user if he or she wish to perform the operation again. if so the loop should repeat, otherwise it should terminate. write a phyton code for this one:

  • USE JAVA. Just a basic code. We these in Blue J 2) Write a while loop...

    USE JAVA. Just a basic code. We these in Blue J 2) Write a while loop that lets the user enter a number. The number should be multiplied by 10 and the result stored in the variable product. The loop should iterate as long as product contains a value less than 100. 3) Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user should be asked if...

  • In Java, write a program using a loop that asks the user to enter a series...

    In Java, write a program using a loop that asks the user to enter a series of decimal numbers. The user must enter -88 to end the input of the decimal numbers. After the user enters all numbers, the program should display the sum of all numbers entered.

  • Write a java program that makes use of the ‘DO WHILE ’ loop. The program asks...

    Write a java program that makes use of the ‘DO WHILE ’ loop. The program asks a user to enter information about several of their friends. The information is their last name, the state they live in, their age, and their expected graduation year. After you enter one friend, write out each individually. You must use JOptionPane to input the 4 fields, and to output the 4 fields. Refer to the textbook Code Listing 4-6 to see how to use...

  • Design a program in pseudocode that asks the user to enter a string containing a series...

    Design a program in pseudocode that asks the user to enter a string containing a series of ten single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string except for the highest value digit. You may only use one main module and one sorting function; otherwise, do not modularize your program. For example, if the user enters 5612286470, the sum would be 33. (0+1+2+2+4+5+6+6+7) If there are multiple highest...

  • python program 6 Write an input validation loop that asks the user to enter a number...

    python program 6 Write an input validation loop that asks the user to enter a number in the range of 100 through 1000? 7 Write an input validation loop that asks the user to enter ‘Y’, ‘y’, ‘N’, or ‘n’? 8 How many times the following loop will repeat? cnt = 0    while  cnt != 5: print(cnt) cnt = cnt + 2

  • Design a program that asks the user to enter a series of 20 numbers. The program...

    Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in the array and then display the following data: The lowest number in the array The highest number in the array The total of the number in the array The average of the numbers in the array PLEASE GIVE THE PSEUDOCODE AND CODE IN C PROGRAMMING

  • need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that...

    need help!! c++ HW_6b - Calculate the average Use a do-while loop Write a program that first prompts the user for an upper limit: Enter the number of entries: 5 € (user enters 5) After the user enters a number, the program should prompt the user to enter that many numbers. For example, if the user enters 5, then the program will ask the user to enter 5 values. Use a do-while loop to add the numbers. o With each...

  • Write an infinite while loop that asks the user for their username and password. The loop...

    Write an infinite while loop that asks the user for their username and password. The loop only stops if the username and password for the user are correct. There are only 2 users: the first user’s username is user123 and their respective password is passwrd1, the second user’s username is user234 and their respective password is passwrd2. Expected output/input when loop is to stop: Enter username: user123 Enter password: passwrd1 Welcome user123 !Expected output/input when loop continues:Enter username: user234 Enter...

  • In Small Basic Write a program that asks the user how many numbers s/he wishes to...

    In Small Basic Write a program that asks the user how many numbers s/he wishes to enter into an array and then enters a loop and proceeds to get those numbers from the user and enter them into the array. Once the array has been filled with the numbers, your program then asks the user to make a choice indicating what s/he wishes to do with the numbers in the array. The choices are: TextWindow.WriteLine("Enter 1 to compute and display...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT