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
stiks02 [169]
3 years ago
11

Using the scenario below, answer the following questions:

Computers and Technology
1 answer:
4vir4ik [10]3 years ago
3 0

Answer:

Here is code in java.

import java.util.*;

class Main

{

public static void main (String[] args) throws java.lang.Exception

{

   try{

         boolean flag=false;

         int total_mile=0;

         double avg_mile;

       // part 1, create and initialize array

       int inp[]={2,5,9,11,13,17,20,22,24,26};

       

       System.out.print("miles ran per week: ");

       // print the miles per week of train

       for(int x=0;x<10;x++)

       {

       System.out.print(inp[x]+" ");

       }

        System.out.println();

       //part 2, print the value of index 2 in the list

       System.out.println("value at index 2: "+inp[2]+" miles");

       //part 3, find length of array

       System.out.println("list length: "+inp.length);

     

       // part 4, calculate total mile and average

       for(int y=0;y<10;y++)

       {

       total_mile=total_mile+inp[y];

       }

       System.out.println("total miles ran: "+total_mile+" miles");

       

       avg_mile=total_mile/10.0;

       System.out.println("average no of miles ran= "+avg_mile+" miles");

       

     // part 5, check 4 exist in the list or not

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

       {

       if(inp[k]==4)

       {

       flag=true;

       break;

           }

       }

           if(flag)

           System.out.println("4 exist in the list.");

           else

            System.out.println("4 doesn't exists in the list.");  

       

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create and initialize array with list value equals to 2 and maximum value 26. Print the miles of each week.Then find the value of miles at index 2 in the list.Next find the length of the array and print it.Calculate total miles ran of 10 weeks.Then calculate the average miles by dividing the total with 10. In the array, check 4 exist or not.

Output:

miles ran per week: 2 5 9 11 13 17 20 22 24 26                                                                            

value at index 2: 9 miles                                                                                                  

list length: 10                                                                                                            

total miles ran: 149 miles                                                                                                

average no of miles ran= 14.9 miles                                                                                        

4 doesn't exists

You might be interested in
Given numRows and numColumns, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print
yawa3891 [41]

Answer:

Step by step explanation along with code and output is provided below.

Explanation:

// the outer loop is for printing digits starting from 1 to numRows

// the inner loop is for printing letters starting from 'A' to numCols

//  char cols = 'A';   should not be inside inner loop or outside outer loop, in both these cases char either repeats itself or continues in a sequence. Therefore it must be inside of outer loop

//  int rows = 1;  ensures that row starts at 1

#include <iostream>

using namespace std;

int main()

{

int numRows;

int numCols;

int rows = 1;

cout <<"Enter number of Rows"<<endl;

cin>>numRows;

cout <<"Enter number of Columns"<<endl;

cin>>numCols;

cout<<"Seats in the theater are:"<<endl;

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

{

  char cols = 'A';  

 for(int j = 0; j < numCols; j++)

 {

  cout <<rows << cols << " ";

  cols= cols + 1;

 }

 rows= rows + 1;

}

  return 0;

}

Output:

When Rows = 2 and Columns = 3

Enter number of Rows

2

Enter number of Columns

3

Seats in the theater are:

1A 1B 1C 2A 2B 2C

When Rows = 4 and Columns = 5

Enter number of Rows

4

Enter number of Columns

5

Seats in the theater are:

1A 1B 1C 1D 1E 2A 2B 2C 2D 2E 3A 3B 3C 3D 3E 4A 4B 4C 4D 4E

Hence program is working correctly for any number of rows and columns

6 0
2 years ago
I ate five M&amp;Ms: red, green, green, red and yellow. Only these three colors are possible. I assume that p(yellow)=3p(green)
Rina8888 [55]

Answer:

Below is code written in a free CAS (WxMaxima):

The above code creates the probability of 19 or more brown in the sample of 48 for population sizes from 5*19 to 10000 in steps of 5.

Here’s a plot of that data:

The horizontal blue line is the probability for an infinite population size (or, choosing each of the 48 M&Ms with replacement, which I infer is not what you meant). It is calculated using the binomial cdf:

The red curve approaches the blue line asymptotically as the population gets larger.

At population 10000, the red curve is

.

5 0
2 years ago
Given three packets of size 2,500 Bytes (caution this is Bytes not bits) each are ready inside computer 1 to be transmitted onto
gizmo_the_mogwai [7]

Answer: umm sorry

Explanation:

5 0
3 years ago
How to make a website
hjlf

Answer:

You need an email and a job and to be over 18 for business ones or a legal gaurdian if you have none then ur hecced uwu :333

8 0
2 years ago
Read 2 more answers
Please help me I don't understand. It's Python.
Vitek1552 [10]
It’s , c probably sorry if I’m wrong
8 0
2 years ago
Read 2 more answers
Other questions:
  • Which statements describe molecules
    12·1 answer
  • A Network Attached Storage device is good for _____.
    11·2 answers
  • A third-grade teacher at Potter Elementary School wants a program that allows a student to enter the amount of money a customer
    14·1 answer
  • 3.26 LAB: Leap Year A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate a
    15·2 answers
  • An ip address in the address range 169.254.x.y, used by a computer when it cannot successfully lease an ip address from a dhcp s
    6·1 answer
  • time to throw poggers xqc time to throw pogchamp time to throw pogchamp time to throw pogchamp time to throw pogchamp time to th
    5·2 answers
  • Question is in photo
    11·1 answer
  • Who's hype for Halo Infinite?
    11·2 answers
  • Write a program to find the sum of first 10 even numbers in qbasic​
    15·1 answer
  • Write a method that makes the input string of sentences ending with and
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!