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
3.24 LAB: Seasons
AveGali [126]

Answer:

Seasons Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day. Ex: If the input is: April 11 the output is: Spring In addition, check if the string and int are valid (an actual month and day). Ex: If the input is: Blue 65 the output is: Invalid Invalid The dates for each season are: Spring: March 20 - June 20 Summer: June 21 - September 21 Autumn: September 22 - December 20 Winter: December 21 - March 19 LAB ACTIVITY 3.24.1: LAB: Seasons 0/10 main.cpp Load default template... 1 #include eam> 2 #include <string> 3 using namespace std; 4 5 int main() 6 string inputMonth; 7 int inputDay; 8 9 cin >> inputMonth; 10 cin >> inputDay; 11 12 /* Type your code here. */ 13 14 return; 15 }

3 0
2 years ago
Assume that getPlayer2Move works as specified, regardless of what you wrote in part (a) . You must use getPlayer1Move and getPla
kakasveta [241]

Answer:

(1)

public int getPlayer2Move(int round)

{

  int result = 0;

 

  //If round is divided by 3

  if(round%3 == 0) {

      result= 3;

  }

  //if round is not divided by 3 and is divided by 2

  else if(round%3 != 0 && round%2 == 0) {

      result = 2;

  }

  //if round is not divided by 3 or 2

  else {

      result = 1;

  }

 

  return result;

}

(2)

public void playGame()

{

 

  //Initializing player 1 coins

  int player1Coins = startingCoins;

 

  //Initializing player 2 coins

  int player2Coins = startingCoins;

 

 

  for ( int round = 1 ; round <= maxRounds ; round++) {

     

      //if the player 1 or player 2 coins are less than 3

      if(player1Coins < 3 || player2Coins < 3) {

          break;

      }

     

      //The number of coins player 1 spends

      int player1Spends = getPlayer1Move();

     

      //The number of coins player 2 spends

      int player2Spends = getPlayer2Move(round);

     

      //Remaining coins of player 1

      player1Coins -= player1Spends;

     

      //Remaining coins of player 2

      player2Coins -= player2Spends;

     

      //If player 2 spends the same number of coins as player 2 spends

      if ( player1Spends == player2Spends) {

          player2Coins += 1;

          continue;

      }

     

      //positive difference between the number of coins spent by the two players

      int difference = Math.abs(player1Spends - player2Spends) ;

     

      //if difference is 1

      if( difference == 1) {

          player2Coins += 1;

          continue;

      }

     

      //If difference is 2

      if(difference == 2) {

          player1Coins += 2;

          continue;

      }

     

     

  }

 

  // At the end of the game

  //If player 1 coins is equal to player two coins

  if(player1Coins == player2Coins) {

      System.out.println("tie game");

  }

  //If player 1 coins are greater than player 2 coins

  else if(player1Coins > player2Coins) {

      System.out.println("player 1 wins");

  }

  //If player 2 coins is grater than player 2 coins

  else if(player1Coins < player2Coins) {

      System.out.println("player 2 wins");

  }

}

3 0
3 years ago
Find examples of conic sections in art and architecture. Visit Web sites to find pictures of artwork or buildings that illustrat
liubo4ka [24]

The question above wants to assess your interpretation of conic shapes and sections in art and architecture. For that reason, I can't write an answer for you, but I'll show you how to write it.

The conical sections can be seen in structures that assume one of the shapes considered conical. These formats are easy to identify, especially in architecture, where they are very popular. These shapes can be classified as Parabola, Circle, Ellipse, and Hyperbole

In this case, to write your answer, you should search for architectural works or works of art that present one of these types of conic sections and show how the use of this format is important for these works.

Some examples of works that use conic sections are:

  • Parabola: Eiffel Tower.
  • Circle: Farmer's Cottage Deluxe Summer House
  • Ellipse: Tycho Brahe Planetarium.
  • Hyperbole: McDonnell Planetarium

More information:

brainly.com/question/2285436

8 0
2 years ago
1. When the Cisco 2950 switch is first turned on, it behaves like a hub. Why is this so, and what must happen before the switch
Sav [38]

Answer:

The switch sends broadcast traffic to all ports like a hub to get the number of ports used and build its MAC address table.

Explanation:

A network switch is a device used in a LAN to connect all available workstations. Unlike a network hub, it is able to send frames from a host or workstation to another using its MAC address table.

An example of a switch is the Cisco 2950 switch. When it is first turned on, it acts as a hub, broadcasting traffic to all its ports. This process is used to create a MAC address table to get the IP address of workstations and the ports they relate to, enabling it to send unicast traffic to a specific port.

7 0
3 years ago
1) You are working with an organization as a network manager. The organization has
pantera1 [17]

Answer:

Explanation:

a. In this specific scenario, the best option would most likely be a site-to-site VPN. This would allow each office to be independently connected to the internet and at the same time be connected to each other securely and efficiently. There should be unnoticeable or no delay at all between the two offices and sensitive files will be completely secure. Therefore, the two offices can easily transfer data securely between one another without fear of the data being intercepted.

b.  The same VPN network would work on the head office, but instead we can implement firewall restrictions to the head office network itself. These restrictions would prevent any or all incoming connections that are trying to request data from the local head office network. This would allow the head office to continue working without worry of unwanted intruders in their network.

7 0
3 years ago
Other questions:
  • Which social media marketing concept engages visitors, getting them to revisit your website and tying them to offline events for
    7·2 answers
  • Which is a copyright
    5·1 answer
  • What term best describes the way the dns name space is organized?
    9·1 answer
  • A light or optical microscope most commonly used is called a(n) _____. bright-field microscope dark-field microscope electron mi
    8·2 answers
  • c++ You are given an array A representing heights of students. All the students are asked to stand in rows. The students arrive
    5·1 answer
  • Zach would like to reuse a spreadsheet that he created last year. However, he will need to delete the contents of several cells.
    5·1 answer
  • Which of these is one of the primary concerns for protecting your family when online?
    9·2 answers
  • 5. How would you describe the relationship between blocks of code and commands?​
    14·2 answers
  • Select the correct answer from each drop-down menu.
    7·1 answer
  • You are considering using Wi-Fi triangulation to track the location of wireless devices within your organization. However, you h
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!