answer.
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
Sloan [31]
2 years ago
3

Write a complete program that reads 6 numbers and assigns True to variable isAscending if the numbers are in ascending order. Ot

herwise assign False to it. Display the value of isAscending. Here are three sample runs: Sample Run 1 Enter six numbers: 4 6 8 10 11 12 True Sample Run 2 Enter six numbers: 4 6 3 10 11 12 False Sample Run 3 Enter six numbers: 41 6 3 10 11 12 False Note: Your program must match the sample run exactly.
Computers and Technology
1 answer:
kolbaska11 [484]2 years ago
3 0

Answer:

<em>The programming language is not stated;</em>

<em>For this, I'll answer your question using c++ programming language</em>

<em>The program does not make use of comments (See explanation for further details)</em>

<em>From the sample run, the input numbers are integer; So, this program assumes that all input will be integer...</em>

<em>Program starts here</em>

#include<iostream>

using namespace std;

int main()

{

cout<<"Enter six numbers: ";

int Arr[6];

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

{

 cin>>Arr[i];

}

bool flag = true;

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

{

for(int j = i;j<6;j++)

{

 if(Arr[i]>Arr[j])

 {

  flag = false;

 }

}

}

string isAscending;

if(flag)

{

isAscending = "True";

}

else

{

isAscending = "False";

}

 

cout<<isAscending;

return 0;

}

Explanation:

cout<<"Enter six numbers: ";  -> This line prompts the user for input

int Arr[6]; -> The input is stored in an array; This line declares the array

The following for loop iteration is used to iterate through the array

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

{

 cin>>Arr[i];  -> This line accepts user input

}

bool flag = true;  -> A boolean variable is initialized to true

The following nested loop checks if numbers are in ascending order

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

{

for(int j = i;j<6;j++)

{

 if(Arr[i]>Arr[j])  -> This particular if statement checks if a number is greater than the next number

 {

  flag = false;  -> If yes, the boolean variable is changed to false

 }

}

}  - > The nested loop ends here

string isAscending  = "True";  -> Here, isAscending is declared as string

if(flag)  If boolean variable flag is true; i

{

isAscending = "True";  "True" is assigned to isAscending

}

else  -> Otherwise; if boolean variable flag is no longer true; i.e if it's false

{

isAscending = "False"; -> "False" is assigned to isAscending

}

cout<<isAscending;  -> The corresponding value of isAscending is printed

You might be interested in
A vehicle fails an HC emission test at idle and 2,500 rpm, and the engine has an acceleration stumble. The heated oxygen sensor
Natalija [7]

I would say a defective O2 sensor

6 0
2 years ago
15 points. Please give an actual answer and not some random thing. this is not just free points. Correct answer will receive bra
trapecia [35]

Answer:

i think its b

Explanation:

i did the test and got it right

7 0
2 years ago
Read 2 more answers
You and your friend who lives far away want to fairly and randomly select which of the two of you will travel to the other’s hom
Phantasy [73]

Answer:

c. your friend can hash all possible options and discover your secret.

Explanation:

SHA-256 is a set of hash functions that was designed by the NSA. SHA-2 is considered an upgrade on the set that was its predecessor, SHA-1. A hash is a mathematical function that condenses data in a process of one-way encryption. SHA-256 creates hash algoritms that are considered irreversible and unique. However, one of the properties of hashing algorithms is determinism, which means that any computer in the world would be able to compute a particular hash and get the same answer.

6 0
2 years ago
given:an int variable k,an int array currentMembers that has been declared and initialized,an int variable memberID that has bee
Oksi-84 [34.3K]

Answer:

// The code segment is written in C++ programming language

// The code segment goes as follows

for (k = 0; k < nMembers; k++)

{

//check if memberID can be found in currentMembers

if (currentMembers[k] == memberID){

// If yes,

// assigns true to isAMember

isAMember = true;

k = nMembers;

}

else{

isAMember = false;

// If no

// assigns false to isAMember

}

}

// End of segment:

The following assumption were made in the code segment above.

There exists

1. An already declared and initialised int array currentMembers.

2. An already initialised int variable memberID

Line 3 initiates a loop to scan through the array

Line 6 checks for the condition below

If current element of array equals memberID then

It assigns true to isAMember and nMembers to k

Else

It assigns false to isAMember

7 0
2 years ago
Meadowdale Dairy Farm sells organic brown eggs to local customers. It charges $3.25 for a dozen eggs, or 45 cents for individual
svp [43]

Answer:

Explanation:

import java.Util;

public class Eggs{

public static void main (String [] args)

{

int noOfEggs, dozen, units;

float total;

Scanner input = new Scanner(System.in);

noOfEggs = input.nextInt();

if(noOfEggs < 0)

{

System.out.print("Invalid");

}

else

{

if(noOfEggs >= 12)

{

dozen = noOfEggs/12;

units = noOfEggs % 12;

}

else

{

dozen = 0;

units = noOfEggs;

}

total = dozen * 3.25 + (units * 45)/100;

System.out.print("You ordered "+noOfEggs+" eggs.\n");

System.out.print("That's "+dozen+" dozen at $3.25 per dozen and "+units+" loose eggs at 45 cents each for a total of $"+total);

}

}

}

7 0
2 years ago
Other questions:
  • A two-dimensional array can have elements of ________ data type(s).
    7·1 answer
  • Using evidence to dispel myths or false beliefs is one way to move closer to evidence-based practice. Please select the best ans
    13·2 answers
  • An online game is played with two dice. In this context, explain what is meant by decomposition in a simple way.
    15·1 answer
  • ANSI defines four events that signal the end of a transaction. Of the following events, which is defined by ANSI as being equiva
    14·1 answer
  • #Remember that Fibonacci's sequence is a sequence of numbers
    14·1 answer
  • What term describes one or more characters following the last period in a filename, such as .exe, .txt, or .avi?
    9·1 answer
  • Consider the following 3-PARTITION problem. Given integers a1; : : : ; an, we want to determine whether it is possible to partit
    10·1 answer
  • Consider two vectors that are NOT sorted, each containing n comparable items. How long would it take to display all items (in an
    8·1 answer
  • PLEASE HELP!!~~
    7·1 answer
  • Directions
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!