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
Alisiya [41]
3 years ago
10

Create a conditional expression that evaluates to string "negative" if userVal is less than 0, and "non-negative" otherwise. Ex:

If userVal is -9, output is:
-9 is negative. PLEASE USE C++
Computers and Technology
1 answer:
Goryan [66]3 years ago
5 0

Answer:

PROGRAMMING APPROACH:

  • Define the necessary header file using namespace.
  • Define the main() method.
  • Declare variable inside the function().
  • Print result.

Explanation:

Required C++ Code:

#include<iostream>

#include<string>

using namespace std;

int main()

{

  string condStr;

  int userVal;

  cin>>userVal;

  condStr=(userVal<0)?("negative"):("non-negative");

  cout<<userVal<< " is "<< condStr <<"."<<endl;

}

OUTPUT:

-2

-2 is negative.

You might be interested in
Why is Thomas Jefferson considered an accomplished man , or a Renaissance man?​
lesantik [10]
The term “Renaissance man” means for a very clever person to be good at many different things.
4 0
3 years ago
Is space between lines of program code that makes the code easier to read and that the compiler ignores?
MAXImum [283]
<span>The space between the lines of program codes make the code easier to read.  This is used by programmers to make their programs more readable and clear.  The space between the lines is not recognized by the compiler, thus it is ignored by the compiler.</span>
3 0
3 years ago
(Java) Meadowdale Dairy Farm sells organic brown eggs to local customers. It charges $3.25 for a dozen eggs, or 45 cents for ind
zepelin [54]

import java.util.Scanner;

public class Eggs {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("How many eggs?");

       int eggs = scan.nextInt();

       int dozens = eggs / 12, ind = eggs - (dozens*12);

       

       System.out.println("You ordered "+eggs+" eggs. That's "+dozens+" at $3.25 per dozen and "+ind+" loose eggs at 45 cents each for a total of $"+((dozens*3.25)+(ind*0.45))+".");

   }

   

}

I hope this helps!

8 0
3 years ago
Which of these protects against the most common attacks on the internet via a database of signatures, but at the same time actua
BartSMP [9]

Answer:

Antivirus Software

Explanation:

The software that the question is describing is known as an Antivirus Software. Like mentioned, this is a computer program that is used with the main goal of preventing, detecting, and removing malicious files on the computer known as computer viruses. They also act as a shield to prevent these malicious files from entering the computer through the internet, but like any other software these Antivirus Softwares can be exploited by hackers to gain access into a system.

5 0
3 years ago
Python Code that predicts the amount of money you will have in your IRA when you retire. Inputs are: 1. Number of years until yo
zaharov [31]

Answer:

yearsUntilRetire =0

expectedInterest =-1.00

initialAmount =-1.0

expectedAmountToAdd = -1.00

while yearsUntilRetire < 1 or yearsUntilRetire > 70:

yearsUntilRetire = int(input("Number of year until you retire between 1 to 70: "))

while expectedInterest <0 :

expectedInterest = float(input("enter the expected rate : "))

if expectedInterest >= 10:

doubleCheckRate = input("do you really expect {} interest rate: ".format(expectedInterest)).lower()

if doubleCheckRate == "false":

expectedInterest =-1.00

while initialAmount < 0:

initialAmount = float(input("Enter positive initial amount for IRA: "))

while expectedAmountToAdd < 0 or expectedAmountToAdd > 2500:

expectedAmountToAdd = float(input("Enter positive IRA amount to be added each year between 0 to $2500: "))

finalContribution =initialAmount

for i in range(yearsUntilRetire):

finalContribution = finalContribution + finalContribution * (expectedInterest/100.00) + expectedAmountToAdd

if (i+1) % 5 == 0:

print("Contribution after year {} is ${:,.2f}.".format(i+1,finalContribution))

 

print("Final Contribution is ${:,.2f}.".format(finalContribution))

Explanation:

  • Use a loop to get the valid input from the user for years until retire between 1 to 70 .
  • Get the valid input for expected rate .
  • Check if expected rate is greater than or equal to 10 then ask the user again if one expect such high rate .
  • Use a loop to get valid IRA initial Contribution .
  • Use a loop to get expected Amount to add regularly in IRA .
  • Iterate over numbers of year and print the data after 5 years .
3 0
3 years ago
Other questions:
  • What number is needed to complete the pattern 66, 73, 13, 21, 52,_, 10, 20?
    12·1 answer
  • Lucy has to move data from column A to column N in a worksheet. Which keys should she select to move data in the same worksheet?
    7·2 answers
  • Explain the difference between an i/o‐bound process and a cpu‐bound process.
    12·1 answer
  • Java: Literal representing the true value ? In java, what is the literal that represents a true value ?
    6·1 answer
  • How are web design &amp; web development different from each other?
    9·1 answer
  • Cho 3 lớp như hình, viếtchương trình thực hiện các chức năng sau:
    15·1 answer
  • What are the words that make up a high-level programming language called?
    6·1 answer
  • What software tool can you use to see the applications that are currently running?
    5·2 answers
  • the volume of two similar solids are 1080cm and 1715cm .if the curved surface area of the smaller cone is 840cm .fond the curved
    5·1 answer
  • Create a text file content.txt and copy-paste following text (taken from Wikipedia) into it: A single-tasking system can only ru
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!