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
Marysya12 [62]
2 years ago
5

4.7 code practice question 2 edhesive i cant figure out the code for this problem csn anyone help me?

Computers and Technology
1 answer:
rodikova [14]2 years ago
8 0

Answer:

See Explanation

Explanation:

<em>See attachment for complete question</em>

The programming language is not stated; I'll answer using Python and Java

Python:

low = 56

high = 70

for i in range(low,high+1):

    print(i)

Java:

public class PrintOut{

public static void main(String [] args)

{

int low = 56; int high = 70;

for(int i = low; i<=high;i++)

System.out.print(i+" ");

}

}

For both codes, the explanation is:

The code starts by initializing the range of the print out to 56 and 70

Next, the code segment used an iteration that loops through 56 and 70 and print each digit in this range (both numbers, inclusive).

You might be interested in
Write a program that simulates flipping a coin repeatedly and continues until three consecutive heads. are tossed. At that point
quester [9]

Answer and Explanation:

#include <iostream>

#include <string>

#include <time.h>

#include <vector>

using namespace std;

//Takes user info

int user_info(string *name,char *gender){

   char G;

   cout<<"What is your name?: ";

   getline(cin, *name);

   cout<<"What is your gender(m/f):";

   cin>>G;

   cout<<endl;

   *gender = tolower(G);

   return 0;

}

//Toss coin(part 2)

bool coin_toss(double seed){

   double r;

   r = (double)seed/(double)RAND_MAX;

   //cout<<r;

   if (r<0.5) return true;

   return false;

}

//check results

float toss_result(vector<char> v,int *h){

   int num_heads=0;

   int num_toss = v.size();

   *h = 0;

   for(int i=0;i<num_toss;i++){

       if(v[i]=='h'){num_heads++;(*h)++;}

   }

   return (float)num_heads/(float)num_toss;

}

void show_result(int total_num,int head_num,float ratio){

   cout<<"it took you "<<total_num<<" tosses to get 3 heads in a row"<<endl;

   cout<<"on average you flipped heads "<<(ratio*100)<<"% of the time"<<endl;

}

int main()

{

   string name;

   char gender;

   string K; //Mr or Mrs

 

   cout<<"Welcome to coin toss! Get 3 heads in row to win!"<<endl;

 

   //part 1

   user_info(&name,&gender);

 

   if(gender == 'f') K = "Mrs.";

   else K = "Mr.";

 

   cout<<"Try to get 3 heads in a row. Good luck "<<K<<name<<"!"<<endl;

   char dummy = getchar();

 

   //part 2

   int num_toss;

   vector<char> toss_results;//store toss results

   bool result;//result of toss

   srand(time(0));

   while(true){

       //cout<<rand()<<endl;

       result = coin_toss(rand());

       cout<<"Press <enter> to flip"<<endl;

       while (1)

       {

           if ('\n' == getchar())

           break;

       }

     

 

     

       if(result) {toss_results.push_back('h');cout<<"HEAD"<<endl;}

       else {toss_results.push_back('t');cout<<"TAIL"<<endl;}

     

       num_toss = toss_results.size();

     

       if(num_toss>=3){

           if ((toss_results[num_toss-1] == 'h')&&(toss_results[num_toss-2] == 'h')&&(toss_results[num_toss-3] == 'h')){

               break;

           }

       }

   }

 

   //part 3

   float ratio_head;

   int num_of_heads;

   ratio_head = toss_result(toss_results,&num_of_heads);

 

   //part 4

 

   show_result(toss_results.size(),num_of_heads,ratio_head);

 

   return 0;

}

8 0
3 years ago
How does a MIPS Assembly procedure return to the caller? (you only need to write a single .text instruction).
AnnyKZ [126]

Answer:

A MIPS Assembly procedure return to the caller by having the caller pass an output pointer (to an already-allocated array).

8 0
3 years ago
To celebrate earth day, the employees of a company plan to reduce their carbon footprint in the workplace. Identify the changes
andrew11 [14]
<span>Go paperless. 
Use natural lighting. 
Grow trees nearby. 
Reduce, reuse, and recycle. 
Carpool. 
</span>
5 0
3 years ago
Read 2 more answers
Mary uploaded some images on her website. She chose an image and downloaded it. She found that the image she saw on screen did n
zalisa [80]

Answer:

A.

Some image resolution was lost while uploading it

As she uploaded them on her website not downloading as choice B&D show while E is false and C is rarely occur

7 0
3 years ago
What is networking??????????????????????
kodGreya [7K]

Answer:

the activity or cycle of collaborating with others to trade data and create proficient or social contacts.

Explanation:

<3

8 0
3 years ago
Other questions:
  • C2.5 - A group of four pirates has a treasure chest and one unique lock and key for each pirate. Using hardware that is probably
    6·1 answer
  • Sam has installed a new CPU in a client’s computer, but nothing happens when he pushes the power button on the case. The LED on
    14·1 answer
  • How many points are in an inch? <br> A 24<br> B 50<br> C 72<br> D 100
    5·1 answer
  • You have activated pop-up blockers in your web browser to prevent pop-up windows from continually interrupting your browsing exp
    14·2 answers
  • I have $80 and I want a smartphone that you can call for free what should I get
    14·2 answers
  • Controlling access of information on the internet
    15·1 answer
  • What is a command-line program?
    8·2 answers
  • Can someone please help me I need to turn this in my 3:00pm Eastern time
    12·1 answer
  • Why must web designers select a common font?​
    8·2 answers
  • search engines use software that combs the web to find webpages and add new data about them to the database. what is this softwa
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!