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
Kobotan [32]
3 years ago
6

Given a int variable named yesCount and another int variable named noCount and an int variable named response write the necessar

y code to read a value into into response and then carry out the following: if the value typed in is a 1 or a 2 then increment yesCount and print out "YES WAS RECORDED" if the value typed in is a 3 or an 4 then increment noCount and print out "NO WAS RECORDED" If the input is invalid just print the message "INVALID" and do nothing else.
Computers and Technology
1 answer:
qaws [65]3 years ago
8 0

Answer:

Explanation:

RESPONSE = stdin.nextInt();

if (RESPONSE== 1 || RESPONSE == 2){

YESCOUNT++;

System.out.println("YES WAS RECORDED");

}

else if (RESPONSE == 3 || RESPONSE== 4){

NOCOUNT++;

System.out.println("NO WAS RECORDED");

}

else

System.out.println("INVALID");

You might be interested in
Write a function called order() thattakes three parameters, and rearranges the integers referred to sothat the largest is first,
gogolik [260]

Answer: The c++ program to implement order() method is given below.

#include <iostream>

using namespace std;

void order(int a, int b, int c);

int main() {

   int x, y, z;

   cout<<"This program displays numbers in descending order."<<endl;

   do

   {

       cout<<"Enter first number"<<endl;

       cin>>x;

       if(x<0)

           cout<<"Invalid input. Enter a positive number."<<endl;

   }while(x<0);

   do

   {

       cout<<"Enter second number"<<endl;

       cin>>y;

       if(y<0)

           cout<<"Invalid input. Enter a positive number."<<endl;

   }while(y<0);

   do

   {

       cout<<"Enter third number"<<endl;

       cin>>z;

       if(z<0)

           cout<<"Invalid input. Enter a positive number."<<endl;

   }while(z<0);

   order(x, y, z);

   return 0;

}

void order(int a, int b, int c)

{

   if((a>b)&&(a>c))

   {  

       cout<<"Numbers in decreasing order are"<<endl;

       cout<<a<<endl;

           if(b>c)

           {

               cout<<b<<endl;        

               cout<<c<<endl;

           }

           else

           {

               cout<<c<<endl;

               cout<<b<<endl;

           }

   }    

   if((b>a)&&(b>c))

   {  

       cout<<"Numbers in decresing order are"<<endl;

       cout<<b<<endl;

           if(a>c)

           {

               cout<<a<<endl;        

               cout<<c<<endl;

           }

           else

           {

               cout<<c<<endl;

               cout<<a<<endl;

           }

   }    

   if((c>b)&&(c>a))

   {  

       cout<<"Numbers in decreasing order are"<<endl;

       cout<<c<<endl;

           if(a>b)

           {

               cout<<a<<endl;        

               cout<<b<<endl;

           }

           else

           {

               cout<<b<<endl;

               cout<<a<<endl;

           }

   }

       

}

OUTPUT

This program displays numbers in descending order.

Enter first number

12

Enter second number

-9

Invalid input. Enter a positive number.

Enter second number

0

Enter third number

55

Numbers in decreasing order are

55

12

0

Explanation:

The method order() is declared as follows.

void order(int a, int b, int c);

The method is declared void since it does not return any value.

This program is designed to accept 0 and positive integers only. This is implemented by do-while loop while taking user input.

The program uses 3 integer variables to store the user input.

int x, y, z;

The method order() is designed to accept 3 integer parameters. This method is called once user enters valid input.

order(x, y, z);

These numbers are compared in order to display them in descending order.

No variable is used for comparison. The method simply compares the numbers and displays them using multiple if-else statements.

4 0
3 years ago
Select the correct answer.
ella [17]

Answer:

Python

Explanation:

8 0
3 years ago
What does the following code do? Assume "list" is an array of int values, "temp" is some previously initialized int value, and "
____ [38]

Answer:

Counting the number of elements in the array list smaller than temp.

Explanation:

We have an array list,a previously initialized integer temp and a an integer c initialized with 0.

In the code a for loop is used to iterate over the array and it is checking if the element at jth index is less than temp if it is then increasing the variable c by 1.

Hence when the loop ends the c will be having the count of the integers in array list that are smaller than temp.

6 0
4 years ago
Given an array temps of double s, containing temperature data, compute the average temperature. Store the average in a variable
Ket [755]

Answer:

#include <iostream>

using namespace std;

// average function

void average(double arr[], int n) {

double total = 0;

double avgTemp;

for (int i = 0; i < n; i++)

{

 // find temperatures total

 total = total + arr[i];

}

// find average

avgTemp = total / n;

cout << "\nAverage Temperature = " << avgTemp << endl;

}

// print temps[] array

void printArray(double arr[], int n) {

for (int i = 0; i < n; i++)

{

 cout << arr[i] << "   ";

}

}

int main() {

int const k = 5;

double temps[k];

// temperature value

double tempValue;  

// Enter 5 temperatures of your choice

for (int i = 0; i < k; i++)

{

 cout << "Enter Temperature value " << i+1 << ": ";

 cin >> tempValue;

 temps[i] = tempValue;

}

// Function call to print temps[] array

printArray(temps, k);  

// Function call to print average of given teperatures

average(temps, k);        

return 0;

}

Explanation:

• Inside main(), int constant k is created to set the maximum size of array temps[].

• tempValue of  type double takes value at a given index of our temps[] array.

• the for loop inside main() is used to get tempValue from the user and store those values in our array temps[].

• after that printArray() function is called. to pass an array to a function it requires to perimeters 1) name of the array which is temps in our case. 2) maximum number of the index which is  k.

• note the syntax of void average(double arr[], int n). Since we are passing an array to the function so its formal parameters would be arr[] and an int n which specifies the maximum size of our array temps[].

6 0
3 years ago
If you would like to give another user permissions on your mailbox or to particular folders within your mailbox, which role shou
Viktor [21]

Answer:

Assignee

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Which statement is true
    12·1 answer
  • Widgets are ___________ a. objects b. icons c. functions d. components
    11·1 answer
  • If a person was on board a hypersonic airplane what do you think they would be able to see as they look out a window looking in
    13·2 answers
  • Describe the GRANT statement and explain how it relates to security. What types of privileges may be granted? How are they revok
    15·1 answer
  • Cost Benefit Analyses (CBAs) cannot be calculated after controls have been functioning for a time, as observation over time prev
    13·1 answer
  • You cannot legally install macOS on a PC that originally came with Windows<br> True or false
    13·2 answers
  • Which of the following is a Microsoft solution
    11·1 answer
  • Whe you read anything online how do you know whether or not is coming from a reliable source?
    14·2 answers
  • Write a line of code to convert time to hours. Remember there are 60 minutes in an hour. Then write a line of code to calculate
    9·2 answers
  • What is not recyclable in a<br> hybrid car<br> hydrogen car<br> petrol car
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!