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
Dennis_Churaev [7]
3 years ago
6

Lab Assignment 7A For the lab this week, you will sort an array - using any of the sort methods discussed in Chapter 23 or the S

election sort. It's your choice. Use the following criteria for your assignment: Write a program that uses a two-dimensional array to store daily minutes walked and carb intake for a week. Prompt the user for 7 days of minutes walked and carb intake; store in the array. Write a sort ( your choice which sort ) to report out the sorted minute values -lowest to highest. Write another to report out the sorted carb intake - highest to lowest. These methods MUST be your original code. Your program should output all the values in the array and then output the 2 sorted outputs. You must use an array to receive credit for this assignment
Computers and Technology
1 answer:
zhuklara [117]3 years ago
8 0

Answer:

See explaination

Explanation:

import java.util.Scanner;

public class sort {

static void lowestToHighest(float arr[][])

{

float temp;

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

for(int j=0;j<12-i-1;j++) //Using bubble sort to sort

{

if(arr[j][0]>arr[j+1][0])

{

temp = arr[j][0];

arr[j][0] = arr[j+1][0];

arr[j+1][0] = temp;

}

}

for(int i=0;i<11;i++) //Using bubble sort to sort

{

for(int j=0;j<12-i-1;j++)

if(arr[j][1]>arr[j+1][1])

{

temp = arr[j][1];

arr[j][1] = arr[j+1][1];

arr[j+1][1] = temp;

}

}

System.out.println("Data in the array after sorting lowest to highest: ");

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

System.out.printf(arr[i][0]+" "+arr[i][1]+"\n");

}

static void highestToLowest(float arr[][])

{

float temp;

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

for(int j=0;j<12-i-1;j++) //Using bubble sort to sort

{

if(arr[j][0]<arr[j+1][0])

{

temp = arr[j][0];

arr[j][0] = arr[j+1][0];

arr[j+1][0] = temp;

}

}

for(int i=0;i<11;i++) //Using bubble sort to sort

{

for(int j=0;j<12-i-1;j++)

if(arr[j][1]<arr[j+1][1])

{

temp = arr[j][1];

arr[j][1] = arr[j+1][1];

arr[j+1][1] = temp;

}

}

System.out.println("Data in the array after sorting highest to lowest: ");

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

System.out.printf(arr[i][0]+" "+arr[i][1]+"\n");

}

public static void main(String[] args){

float temperature[][]=new float[12][2];

Scanner input = new Scanner(System.in);

System.out.println("Enter 12 months of highest and lowest temperatures for each month of the year: ");

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

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

temperature[i][j]=input.nextFloat();

System.out.println("Data in the array: ");

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

System.out.printf(temperature[i][0]+" "+temperature[i][1]+"\n");

lowestToHighest(temperature);

highestToLowest(temperature);

}

}

You might be interested in
What is the purpose of requirements gathering
inn [45]

Answer:

to determine customer needs for a software

application

to reduce over scheduling of project

resources

Explanation:

Requirement gathering and analysis involves a business analyst and the client. And this is done in various phases with the first phase involving the business analyst and the client. And the second phase of software requirement is also being covered, and that is done by a team of System analysts, business analyst, and technical writers are part of both the team. However, both the phases have nothing to do with the bugs, and hence the first and the third part is not the correct part. However, customer needs are noted down, and in the second phase when resource requirement other than technical requirement is studied, partly it is ensured that there is no over the scheduling of the project resources during the project. And hence the second and the fourth options are the correct options.

3 0
3 years ago
Read 2 more answers
Identify a true statement of a JavaScript program in a web form.
zalisa [80]

Answer:

The answer is option(a).

Explanation:

JavaScript is a language for client scripting, that is used to generate web pages. This language is developed for a standalone platform like Netscape. It is used to create a dynamic web page as well as to add some new effects to websites. The JavaScript can be moved on to the CGI system on a web page and the JavaScript code involving the necessary data may be returned by a CGI program. and other options are not correct that can be defined as:

  • In option b, JavaScript is not a closed-source programming language.
  • In option c, It is not configured for actuators engines.
  • In option d, It is not a bug-free language.
7 0
3 years ago
Define function print_popcorn_time() with parameter bag_ounces. If bag_ounces is less than 3, print "Too small". If greater than
yawa3891 [41]

Answer:

void print_popcorn_time(int bag_ounces){

   if(bag_ounces < 3){

       cout<<"Too small"<<endl;

   }else if(bag_ounces > 10){

       cout<<"Too large"<<endl;

   }else{

       cout<<(6 * bag_ounces)<<"seconds"<<endl;

   }

}

Explanation:

The function is the block of the statement which performs the special task.

For checking the condition in the program, the if-else statement is used.

It can check the condition one or two but if we want to check the more than two different conditions then the continuous if-else statement is used.

syntax of continuous if else:

if(condition){

statement;

}else if(condition)

statement;

}else{

statement;

}

In the question, there are three conditions;

1. bag_ounces is less than 3

2. bag_ounces greater than 10

3. else part.

we put the condition in the above if-else statement and print the corresponding message.

8 0
3 years ago
Read 2 more answers
You are an administrator for a large corporation and you are responsible for deploying computers often and quickly. Which server
sashaice [31]

Answer:

The deployment method to use is called Zero touch deployment

Explanation:

Zero-touch deployment or installation is considered as a high volume installation procedure for large and medium organizations. Many computers are configured remotely through the help of the command line. With this process computers are deployed often and quickly because the installations are automated.

The benefits of zero-touch deployment include the following:

  1. Easy distribution of computer resources. Resources are scarce in business, hence, there is a great need to be able to recycle business resources as often and quickly as possible.
  2. Reduces operational costs. Businesses are focused on reducing the operational cost to the barest minimum because deployment can be easily managed by internal staff, deploying zero-touch deployment will greatly reduce operational cost.
5 0
3 years ago
2. The factorial of a positive integer n is the product of the integers from 1 to n. You can express the factorial of a positive
Molodets [167]

Answer:

import java.io.*;

import java.util.Scanner;//importing the scanner.

class Factorial {

public static void main (String[] args) {

    Scanner fact=new Scanner(System.in);//creating a scanner object for taking the input.

    int t,n;//t for number of times the user want to calculate the factorial and n for factorial.

    System.out.println("How many times you want to calculate the factorial");

    t=fact.nextInt();//taking input of t.

    while(t>0)

    {

        int f=1;//f for calculating the variable.

        n=fact.nextInt();//taking input of n .

        if(n>10||n<1)//if n is out of range then again taking input.

        {

           while(n>10 || n<1)

                {

                        System.out.println("Please Enter the Valid Input");

                 n=fact.nextInt();

                }

               for(int i=1;i<=n;i++)//calculating the factorial.

               {

                   f*=i;

               }

               System.out.println("The factorial is: "+ f);

        }

        else // if n is in  range then definitely calculating the factorial.

        {

             for(int i=1;i<=n;i++)// calculating the factorial.

               {

                   f*=i;

               }

               System.out.println("The factorial is: "+ f);

        }

    }

}

}

Output:-

How many times you want to calculate the factorial

2

-5

Please Enter the Valid Input

4

The factorial is: 24

5

The factorial is: 120

Explanation:

The above written code is for calculating the factorial of an integer the number of times user want to calculate the factorial.The code wants user to enter again until the value entered by the user is in range.If the value is in range then it definitely calculates the factorial.

6 0
3 years ago
Other questions:
  • Which type of media would be best for showing global trade routes?
    7·2 answers
  • Ascending and descending are examples of
    5·2 answers
  • Answer the following questions which are based on the study "Patients' Engagement with Sweet Talk." Submit your answers to the e
    9·1 answer
  • Users generally do not understand the concept of network drive sharing. they only know they can store their files "on my f: driv
    8·1 answer
  • The statement x++;
    11·1 answer
  • What activities are coordinated by the OS?
    11·1 answer
  • Difference between switch case and if else statement.​
    11·1 answer
  • If you need to determine impacts on revenue resulting from an increase or
    15·1 answer
  • When is the kids choiceee awads?????????????????????????
    12·2 answers
  • What techniques are required to accept
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!