1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Stells [14]
3 years ago
15

Java

Computers and Technology
1 answer:
inna [77]3 years ago
3 0

Answer:

import java.util.Scanner;

public class num3 {

   public static void main(String[] args) {

     Scanner in = new Scanner(System.in);

       System.out.print("Enter two numbers: ");

       int num1 = in.nextInt();

       int num2 = in.nextInt();

       int sum = num1+num2;

       System.out.print("Do you want another operation: ");

       String ans = in.next();

       while(ans.equalsIgnoreCase("yes")){

           System.out.print("Enter two numbers:");

           num1= in.nextInt();

           num2 = in.nextInt();

           System.out.println("Do you want another operation: ");

           ans = in.next();

           sum = sum+(num1+num2);

       }

       System.out.println("sum = "+sum);

   }

}

Explanation:

In the program written in Java Programming language,

The scanner class is used to prompt and receive two numbers from the user which are stored as num1 and num2. Another variable sum is created to hold the sum of this numbers

Then the user is prompted to answer yes or no using Java's equal.IgnoreCase() method.

If the user enters yes, he/she is allowed to entered two more numbers that are countinually added to sum

If the user eventually enters a string that is not equal to yes. The loop terminates and the accumulated value of sum is printed.

You might be interested in
Which item is most important for a successful website design?
ahrayia [7]
I believe the answer is keep the target audience in mind
3 0
3 years ago
Read 2 more answers
Consider the following code segment.
Fynjy0 [20]

Answer:

C

Explanation:

10 15 20 35

30 35 40 45

50 55 60 65

6 0
2 years ago
describe a situation in which peer pressure could cause a serious problem for safe driving, and how you could resist the peer pr
Agata [3.3K]
People could pressure you to drink or do drugs etc then drive
you can avoid the problem by staying true to yourself and getting away from those people asap unless they need your help
6 0
2 years ago
Read 2 more answers
In 1970, the federal government created __________ to both assist and require employers and employees to make the prevention of
Aleksandr-060686 [28]

OSHA

Occupational Safety Health Administration

4 0
3 years ago
Which of the following are typically an example of primary resources?
TiliK225 [7]
I believe the answer is B. Biographies and histories. (Otherwise its D)
5 0
3 years ago
Other questions:
  • The place where one printed page ends and the next page begins.
    15·1 answer
  • In addition to talking to other doctors remotely, telegraphy technology?
    5·1 answer
  • When a bank account pays compound interest, it pays interest not only on the principal amount that was deposited into the accoun
    15·1 answer
  • Amazon SWF is restricts you to use a specific programming language when setting up a work flow
    8·1 answer
  • Fred wants to analyze his spending habits of the past few years and has gathered information on the checks he has written from 2
    6·1 answer
  • __________ is a growing practice in cooperative farmingassociations to pool and sell the fruit as a common commodity underthe br
    6·1 answer
  • Write a program which increments from 0 to 20 and display results in Decimal on the console 2-b) Modify above program to increme
    6·1 answer
  • Which line of code will eliminate the element “calculator” from an array of supplies?
    13·1 answer
  • Which term is used in object-oriented programming to reference characteristics of an object?
    15·1 answer
  • What is computer viras? Loist 2 preventive measures against it​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!