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
Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per l
sweet [91]

Answer:

#include<stdio.h>

#define DOLLAR 100

#define QUARTER 25

#define DIME 10

#define NICKEL 5

#define PENNY 1

void calculatedChange(int userAmount,int coinValues[])

{

if (userAmount >=100)

{

coinValues[0]=userAmount/DOLLAR;

userAmount=userAmount-(100*coinValues[0]);

}

if (userAmount >=25)

{

coinValues[1]=userAmount/QUARTER;

userAmount=userAmount-(25*coinValues[1] );  

}

if (userAmount >=10)

{

coinValues[2]=userAmount/DIME;

userAmount=userAmount-(10*coinValues[2]);

}

if (userAmount >=5)

{  

coinValues[3]=userAmount/NICKEL;

userAmount=userAmount-(5*coinValues[3]);

}

if (userAmount >=1)

{

coinValues[4]=userAmount/PENNY;

userAmount=userAmount-coinValues[4];

}

}

int main() {

int amount;

printf("Enter the amount in cents :");

scanf("%d",&amount);

if(amount<1)

{

printf("No change..!");

}

else

{

int coinValues[5]={0,0,0,0,0};

calculatedChange(amount,coinValues);

if (coinValues[0]>0)

{

printf("%d Dollar",coinValues[0]);

if(coinValues[0]>1) printf("s");

}

if (coinValues[1]>0)

{

printf(" %d Quarter",coinValues[1]);

if(coinValues[1]>1) printf("s");

}

if (coinValues[2]>0)

{

printf(" %d Dime",coinValues[2]);

if(coinValues[2]>1) printf("s");

}

if (coinValues[3]>0)

{

printf(" %d Nickel",coinValues[3]);

if(coinValues[3]>1) printf("s");

}

if (coinValues[4]>0)

{

printf(" %d Penn",coinValues[4]);

if(coinValues[4]>1) printf("ies");

else printf("y");

}

}

}

Explanation:

  • Create a calculatedChange method for calculating userAmount.  
  • Use conditional statements to check dollars , quarters , dimes , nickels  and penny.
  • Inside the main method , validate the input  and then  print dollars , dimes , nickels after checking them.

7 0
3 years ago
Convert the following pseudocode to C++ code. Be sure to define the appropriate variables. Store 25 in the speed variable. Store
tankabanditka [31]

Answer:

int main()

{

   int speed = 25, time = 15;

   int distance = speed * time;

   cout<<"The distance is: " << distance <<endl;

   return 0;

}

Explanation:

- Initialize the variable <em>speed</em> as 25 and <em>time</em> as 15

- Calculate the <em>distance</em> by multiplying <em>speed</em> and <em>time</em>

- Print the <em>distance</em>

3 0
3 years ago
Where are Micro USB connectors used the most?
jeka94

Answer:

desktops............

3 0
3 years ago
Read 2 more answers
C++ Question (if and while loops)
IceJOKER [234]
Your while statement is in error

<span>while (wage = 0) assigns 0 to wage.

What you want is to compare wage to 0, ie.:

while (wage == 0).

However, comparing double's to some value is very bad practice due to rounding errors. Much safer is to always have a < or > in there:

while (wage < 0.0001)

If you confuse assignment (=) and comparison (==) often, and you don't have a compiler to warn you for this, you can adopt the coding style to put the constant first:

while(0 == x)</span>
8 0
3 years ago
What kind of attack allows for the construction of LDAP statements based on user input statements, which can then be used to acc
abruzzese [7]

Answer:   b. LDAP injection

Explanation:

LDAP (Lightweight Directory Access Protocol ) Injection is defined as

  • an injection attack used by attacker to exploit web based applications by inserting LDAP statements based on user input.
  • It may be possible modify LDAP statements through some techniques if an application fails to properly sanitize user input.

So,<u> LDAP injection</u> is the attack that allows for the construction of LDAP statements based on user input statements, which can then be used to access the LDAP database or modify the database's information.

Hence, the correct option is b. LDAP injection.

4 0
2 years ago
Other questions:
  • Leslie’s form collected a huge amount of data. Over time the employees felt that the applications slowed down. What should lesli
    12·1 answer
  • What error, if any, is in the following code?
    11·1 answer
  • Working at a ski resort in the mountains has its own unique security issues. Kenny is the chief information officer for Sundance
    10·1 answer
  • Explain briefly why every person in the world is not connected to the Internet.
    9·1 answer
  • Does anyone know the answers?
    8·1 answer
  • What is the component on the motherboard that confirms all devices are in working order once the computer is turned on?
    13·1 answer
  • Do pc players ever go outside?
    11·2 answers
  • We have constructed a Player Class for you. Add the following: public static variable: int totalPlayers Static variable should b
    8·1 answer
  • How do people decide their ethical behavior
    13·2 answers
  • What is a software program for navigating the web and displaying websites and pages?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!