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
slavikrds [6]
2 years ago
10

Write a program that allows the user to continuously input the value n until a negative number is entered

Computers and Technology
1 answer:
Paul [167]2 years ago
3 0

Answer:

Written in C++

Explanation:

#include <iostream>

using namespace std;

int main()

{

int n;

while(true)

{

cin>>n;

if(n>=0)

continue;

break;

}

return 0;

}

You might be interested in
Select three advantages of cloud computing.
777dan777 [17]

Answer:

easily managed, large amount of storage capacity, great flexibility

Explanation:

5 0
3 years ago
For this project you will write a Java program that will run a simple math quiz. Your program will generate two random integers
ElenaW [278]

Answer:

Here is the JAVA program:

import java.util.Scanner;   //to accept input from user

public class FunWithBranching {   //class name

   public static void main(String[] args) {  //start of main function

   Scanner input = new Scanner(System.in);  //creates Scanner object

   System.out.print("Enter your name: "); //prompts user to enter name

   String userName = input.nextLine();  //stores the name

   System.out.print("Welcome " + userName + "! Please answer the following questions:\n");   //prompts user to answer the questions

   int randomOperand1 =  (int)(20 * Math.random()) + 1;  //generates random number for operand 1 (1-20)

   int randomOperand2 =  (int)(20 * Math.random()) + 1;  //generates random number for operand 2 (1-20)

   int randomAdd = randomOperand1 + randomOperand2;  //performs addition of two random numbers and stores result in randomAdd

   int randomMul = randomOperand1 * randomOperand2;  //performs multiplication of two random numbers

   int randomDiv = randomOperand1 / randomOperand2;  //performs division of two random numbers

   int randomMod = randomOperand1 % randomOperand2;  //performs modulo of two random numbers

   int correctAns = 0;  //stores number of correct answers

   System.out.print(randomOperand1 + " + " + randomOperand2 + " = ");  //displays random number + random number

   int AdditionGuess = input.nextInt();   //reads the answer of addition from user and stores it in AdditionGuess

   if (AdditionGuess == randomOperand1 + randomOperand2) {  //if the user answer is correct

   System.out.println("Correct!");  //displays correct

   correctAns++;  //adds 1 to the count of correctAns every time the user gives correct answer of addition

 } else {  //if user answer is incorrect

   System.out.println("Wrong!");  //displays wrong

   System.out.println("The correct answer is " + randomAdd);   }  //displays the correct answer of addition

   System.out.print(randomOperand1 + " * " + randomOperand2 + " = ");  //displays random number * random number  

   int MultiplicationGuess = input.nextInt();   //reads the answer of multiplication from user and stores it in MultiplicationGuess

 if (MultiplicationGuess == randomOperand1 * randomOperand2) {  //if the user answer is correct

     System.out.println("Correct!");  //displays correct

     correctAns++;  //adds 1 to the count of correctAns every time the user gives correct answer of multiplication

 }else{  //if user answer is incorrect

       System.out.println("Wrong!");  //displays wrong

       System.out.println("The correct answer is " + randomMul);   }  //displays the correct answer of multiplication

   System.out.print(randomOperand1 + " / " + randomOperand2 + " = ");  //displays random number / random number  

   int DivisionGuess = input.nextInt();   //reads the answer of division from user and stores it in DivisionGuess

   if (DivisionGuess == randomOperand1 / randomOperand2) {  //if the user answer is correct

       System.out.println("Correct!");  //displays correct

       correctAns++;   //adds 1 to the count of correctAns every time the user gives correct answer of division

       }else{  //if user answer is incorrect

           System.out.println("Wrong!");  //displays wrong

           System.out.println("The correct answer is " + randomDiv);     }  //displays the correct answer of division

      System.out.print(randomOperand1 + " % " + randomOperand2 + " = ");  //displays random number % random number  

       int ModGuess = input.nextInt();  //reads the answer of modulo from user and stores it in ModGuess

           if (ModGuess == randomOperand1 % randomOperand2) {  //if the user answer is correct

           System.out.println("Correct!");  //displays correct

           correctAns++;   //adds 1 to the count of correctAns every time the user gives correct answer of modulo

           }else{  //if user answer is incorrect

               System.out.println("Wrong!");  //displays wrong

               System.out.println("The correct answer is " + randomMod);    }  //displays the correct answer of modulo

double percentage = correctAns * 25;   //computes percentage

System.out.println("You got " + correctAns + " correct answers.");   //display number of correct answers given by user

System.out.println("That's " + percentage + "%!");         }  } //displays percentage

Explanation:

The program is well explained in the comments mentioned with each line of code. The screenshot of the output is attached.

3 0
3 years ago
graphic designers can compress files in different formats . One of the formats ensures that the quality and details of the image
musickatia [10]

Answer:

The format that is used is: PNG

Explanation:

7 0
3 years ago
A(n) __________attack is designed to render the target unreachable by legitimate users, not to provide the attacker access to th
Nimfa-mama [501]
Denial of Service or Distributed Denial of Service.
3 0
3 years ago
Any mobile devices contain a(n) ___ and gyroscope that can sense even the smallest movements.
mars1129 [50]

Any mobile device contains a(n) accelerometer and gyroscope that can sense even the smallest movements.

<h3>What are accelerometers? What does an accelerometer sensor do in mobile phones?</h3>

The orientation of a mobile phone is determined by the accelerometer in the device. The gyroscope, or gyro for short, tracks rotation or twist to provide another dimension to the data provided by the accelerometer.

A smartphone's built-in accelerometer measures the device's acceleration. It tracks the different motions like shaking, tilting, swinging, and rotating and accordingly changes the orientation of your app. The accelerometer utilizes the value of XYZ to determine and detect motion.

To know more about accelerometer , Visit:

<u>brainly.com/question/27960990</u>

#SPJ4

7 0
2 years ago
Other questions:
  • How can i put this sign in my keybord?<br><br> :::::<br> ^<br> Here is the sign
    8·1 answer
  • To use a stored address, C provides us with an indirection operator, ____.
    6·1 answer
  • Not providing guarding or fall protection for workers on a 25-foot scaffold. The resulting fall would most likely end in death,
    6·1 answer
  • Ideally an entity identifier is composed of _____ attribute(s).
    11·1 answer
  • __________ refers to rules, statutes, codes, and regulations established to provide a legal framework within which business may
    13·1 answer
  • Computer hardware without software is useless while computer software without hardware is meaningless. Discuss. Plz provide exam
    15·1 answer
  • Consider the following code: // Merge mailing list m2 into m1 void merge (MailingList m1, MailingList m2) { for (int i = 0; i &l
    12·1 answer
  • A solid understanding of __________ is the foundation of verbal communication
    7·1 answer
  • Mention two strategies of collecting data​
    13·1 answer
  • Need answer Asap!!!! Which file type is the best choice if the image will be made into a billboard?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!