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
Diano4ka-milaya [45]
3 years ago
8

[This is on Edhesive (coding and programming)]

Computers and Technology
2 answers:
Ghella [55]3 years ago
6 0

Answer:

Codes are given below:

Explanation:

Since the language is not specified, I am writing it in c++

1) Ask the user to input an integer. Print out the next three consecutive numbers.

#include <iostream>

 using namespace std;

 int main()    //Start of main function

{

  int number;  

   cout << "Enter your number<<endl;

  cin >> number;     //this will take your number as an input

 

  cout <<"The next three numbers are: " << number + 1 << endl;

  cout << number + 2 << endl;

   cout << number + 3 << endl;  

  return 0;

}   //End of main function

2) Write a program that accepts three decimal numbers as input and outputs their sum.

#include <iostream>

 using namespace std;

 int main()    //Start of main function

{

  int number1, number2, number3;  

   cout << "Enter your three numbers<<endl;

  cin >> number1 >> number2>> number3 ;     //this will take your three number as an input

 

  cout <<"The sum of three numbers are: " << number1 + number2+ number3 <<  endl;  

  return 0;

}   //End of main function

egoroff_w [7]3 years ago
6 0

The code is written using Python language as it is one of the programming languages introduced by the Edhesive courses.

Answer (Question 1):

  1. num = int(input("Input an integer: "))
  2. for i in range(1, 4):
  3.    print(num + i)

Explanation (Question 1):

<u>Line 1 : </u>

Prompt user for input an integer.  In Python we can easily use <em>input </em>method to ask user for an input.

However the default data type of the input is a string and therefore we need to enclose our input value within <em>int()</em> to convert the value from string to integer.

<u>Line 3 - 4:</u>

Create a for-loop to loop though the code in Line 4 for three times using the <em>range() </em>function. The <em>range(1, 4) </em>will return a list of numbers, [1, 2, 3] .

In each round of the loops, one number from the list will be taken sequentially and total up with the input number, num and display using <em>print()</em> function.

Answer (Question 2):

  1. counter = 3
  2. sum = 0
  3. while (counter > 0):
  4.    num = float(input("Enter a decimal number: "))
  5.    sum += num
  6.    counter = counter - 1
  7. print("The sum is " + str(sum))

Explanation (Question 2):

<u>Line 1 - 2 :</u>

Create a <em>counter</em> variable and a <em>sum</em> variable and initialize them with 3 and 0, respectively.

<u>Line 4:</u>

Create a <em>while </em>loop and set a condition while counter is bigger than zero, the loop should keep running the code from Line 5-7.

<u>Line 5:</u>

Use <em>input</em> function again to prompt user for a decimal number. This time we need to use<em> float </em>function to convert the input value from string to decimal data type.

<u>Line 6:</u>

Every time when a decimal number is input, the number is added to the <em>sum</em> variable.

<u>Line 7:</u>

Decrement the counter variable by 1. This step is important to ensure the while loop will only be repeated for three times and each loop will only accept one input value from user.

<u>Line 9</u>

Display the sum.

You might be interested in
Why do you think LinkedIn has become so popular?
mart [117]
Because it is a liable source for business.
6 0
3 years ago
Match each method of communication with its intended purpose.
Scorpion4ik [409]

Answer:

1. a late breaking news story = to inform

2. a poetry reading = to entertain

3. an advertisement = to persuade

4. a small group assignment = to collaborate

Explanation:

1. A "breaking news" tells people of what is happening in the society. It <em>informs </em>them of the occurrence of an important event such as the plane crash of Kobe Bryant.

2. Poetry reading is meant to touch the attention of listeners. It tries to entertain them through the poem's interesting verses.

3. An advertisement is being shown/displayed in order to convince people to buy a particular product or service.

4. A group assignment allows the members of the group to contribute their ideas together. Such situation is known as "collaboration." They try to brainstorm together towards a common goal.

7 0
3 years ago
Nicole is in a study group to prepare for a test on plant biology, a subject she knows a lot about. During their meetings, she a
Anestetic [448]

Answer:

b

Explanation:

i pretty sure it b , yep it is b

4 0
3 years ago
Read 2 more answers
Multiple Intelligence Theory explains that...
Alex

Answer:

A. We all learn differently (edge 2020)

Explanation:

4 0
3 years ago
Read 2 more answers
The acronym LAH stands for
Nina [5.8K]
D.Limited Access Highway
5 0
3 years ago
Read 2 more answers
Other questions:
  • Why are application programs stored in main memory​
    11·1 answer
  • Write a program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, conve
    5·1 answer
  • Given a number count the total number of digits in a number
    12·1 answer
  • You want to calculate a bonus if the sold price was at least equal to the listing price, and if the house sold within 30 days af
    6·1 answer
  • Write a program that asks the user to enter a series of single digit numbers with nothing separating them. Read the input as a C
    12·1 answer
  • A binary search algorithm ____________ an ordered list in<br> half to find an item.
    13·1 answer
  • Your friend decides to create a spreadsheet containing vocabulary terms and their definitions to help prepare for the unit test
    5·1 answer
  • Describe some things that this person might say that might cause you to NOT hire them. Explain.
    6·1 answer
  • Say true or false
    10·2 answers
  • Question 1
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!