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
lesantik [10]
3 years ago
9

Write a program that continually prompts the user for an integer input until input is entered that is less than 0. Each input th

at is accepted is appended to an array named inputs, until an invalid input is given. When the first invalid input is entered the program prints the array and exists.
Computers and Technology
1 answer:
professor190 [17]3 years ago
7 0

Answer:

Following are the program in the C++ Programming Language:

#include <iostream>//header file

using namespace std;//namespane

//set main method

int main() {  

int a[100]; //set integer type array variable

int value, i = 0; //set integer variables

cout<<"Enter less than 0 to exit:"<<endl; //message for exit

cout<<"Enter the integer numbers:"<<endl; //message to enter numbers

do{ //set do while

cin>>value; //get input from the user

a[i++] = value; //append elements in array

}while(value>=0);

i--;  

cout<<"\nArray are:"<<endl;//message for array

for(int k = 0;k<i;k++){ //set for loop

cout<<a[k]<<" "; //print array

}

return 0;

}

<u>Output</u>:

Enter less than 0 to exit:

Enter the integer numbers:

1

2

3

4

5

-1

Array are:

1 2 3 4 5

Explanation:

Here, we set the integer data type main method "main()" and inside it:

  • we set integer type array variable with index value 100.
  • we set two integer type variable "value" and "i" initialize value 0.
  • we set the do-while loop in which we get the input from the user and and append in the array and pass condition if the value is greater then equal to 0.
  • Finally, set for loop and print the elements of an array.

 

You might be interested in
Write a statement to create a Google Guava Multimap instance which contains student ids as keys and the associated values are st
Sergeu [11.5K]

Answer: provided in the explanation section

Explanation:

Note: take note for indentation so as to prevent error.

So we import com.google.common.collect.Multimap;

import java.util.Collection;

import java.util.Map;

class Main {

   public static void main(String[] args) {

       // key as studentId and List of Profile as value.

       Multimap<String,Profile> multimap = ArrayListMultimap.create();

       multimap.put("id1", new ExamProfile("examStudentId1"));

       multimap.put("id1", new ELearningProfile("userId1"));

       multimap.put("id2", new ExamProfile("examStudentId2"));

       multimap.put("id2", new ELearningProfile("userId2"));

       // print the data now.

       for (Map.Entry<String, Collection<Profile>> entry : multimap.entrySet()) {

           String key = entry.getKey();

           Collection<String> value =  multimap.get(key);

           System.out.println(key + ":" + value);

       }

   }

}

// assuming String as the studentId.

// assuming Profile as the interface. And Profile can multiple implementations that would be

// specific to student.

interface Profile {

}

class ExamProfile implements Profile {

   private String examStudentId;

   public ExamProfile(String examStudentId) {

       this.examStudentId = examStudentId;

   }

}

class ELearningProfile implements Profile {

   private String userId;

   public ELearningProfile(String userId) {

       this.userId = userId;

   }

}

This code is able to iterate through all entries in the Google Guava multimap and display all the students name in the associated students profile.

8 0
3 years ago
Write a program that computes the monthly net pay of the employee for a steel factory. The input for this program is the hourly
Mars2501 [29]

Answer:

#include<stdio.h>

int main()

{

float rate_of_pay,regular_hours,overtime_hours,grosspay,netpay,tax;

printf("Enter the Hourly rate of pay : ");

scanf("%f",&rate_of_pay);

printf("Enter the number of Regular hours : ");

scanf("%f",&regular_hours);

printf("Enter the number of Overtime hours : ");

scanf("%f",&overtime_hours);

grosspay=(regular_hours*rate_of_pay)+(1.5*overtime_hours*rate_of_pay);

netpay=grosspay-(grosspay*0.2);

printf("Employee's Gross pay = %f\n",grosspay);

printf("Tax = %f\n",0.2*grosspay);

printf("Employee's Net pay = %f\n",netpay);

return 0;

}

Note: The variables are declared as float, to support partial hours like 0.5,6.5 etc.

Explanation:

6 0
3 years ago
Which type of ICS facility is used to temporarily position and account for personnel, supplies, and equipment awaiting assignmen
Black_prince [1.1K]

Answer:

C. Staging Area

Explanation:

According to my research on different ICS facilities, I can say that based on the information provided within the question the facility being described here is called a Staging Area. Like mentioned in the question a staging area is a location set up at an incident where resources and personnel can be placed while waiting on instructions to proceed with an operation or assignment.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

6 0
2 years ago
The best time to visit a college is: A. during spring break. B. on a weekend. C. when the college is in session. D. during winte
GaryK [48]
When the college is in session
5 0
3 years ago
Read 2 more answers
Which does a traditional camera need in order to capture images?
pashok25 [27]

Answer:

I think secure digital is needed

3 0
2 years ago
Other questions:
  • A disk rotates at a rate of 7200 revolutions per minute. Seek operations (i.e., moving the access head to a desired track) take
    6·1 answer
  • 18 Select the correct answer.
    5·1 answer
  • Pinterest is most useful for?
    10·2 answers
  • A ____ operating system should be capable of supporting the applications and tools necessary to support Internet operations.
    10·1 answer
  • Approximately what percent of desktop PCs are used for work-related purposes?
    12·1 answer
  • TRUE OR FALSE!!<br> Your location can be identified simply by turning on your cell phone..
    12·2 answers
  • When entering information for a new contact in the address book, Outlook will automatically create a _____. A. Invitation B. Res
    7·1 answer
  • How do you remove a key cap without a kaycap remover (keyboard keycap) ​
    11·1 answer
  • ____ storage is not recommended for long-term archiving because the storage media can degrade over time
    15·1 answer
  • in the topology configuration, hosts are connected to each other through a central controller which assumes all responsibility f
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!