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]
4 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]4 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 output of the code below assuming that global variable x has value 2 and global y has value 3? def f1(): return "ab"
Lostsunrise [7]

Answer:

ababababab

Explanation:

The code above is written in python and python uses indentation .So let me rephrase the code accordingly and explain what the code really do.

Note x and y is a global variable which can be used by any of the function declared.  According to the question x and y are 2 and 3 respectively

The first block of code describes a function f1 without any argument but the code should return the string "ab"

def f1():

      return "ab"

The second block of code defines a function f2 and returns the value of f1 multiply by x. This means you are multiplying the string "ab" by 2 which will be equals to abab

def f2():

           return f1() * x

The third block of code declared a function f3 and returns the sum of  f2 and product of f1 and y. using PEMDAS principle the multiplication aspect will be solved first so, ab × 3 = ababab, then we add it to f2  . ababab + abab = ababababab.

def f3():

        return f2() + f1() * y

Finally, we print the function f3 value to get ababababab

print(f3())

If you run the code on your IDE like below you will get  ababababab

x = 2

y = 3

def f1():

      return "ab"  

def f2():

      return f1() * x  

def f3():  

      return f2() + f1() * y  

print(f3())

     

7 0
3 years ago
You’ve received a tarball called data79.tar from a colleague, but you want to check the names of the files it contains before ex
Nina [5.8K]

Answer:

D. tar rvf data79.tar

4 0
3 years ago
How did early games in generation 1 or 2 influence zelda botw
Novay_Z [31]

Answer:

Open world exploration and inventory management

Explanation:

In the first Zelda game (NES) and Zelda ii (NES) there were very early open world mechanics along with inventory management.

5 0
3 years ago
Read 2 more answers
Which of the following might be appropriate to be created as a constant variable?
jasenka [17]

Answer:

Number of feet in a mile

Explanation:

In this problem, we need to find an option that to be created as a constant variable.

In option (a) "number of feet in a mile".

As 1 mile = 5280 foot

The number of feet in a mile is constant in every condition.

In option (b), (c) and (d)

number of people inside a store , current grade in a class , score in a football game are no fixed. It is not created as a constant variable.

Hence, the correct option is (a).

7 0
3 years ago
Non linear editing can cause _____ where edit and re-edit and re-edit again can cause video to be less true than the original ma
Oxana [17]

Non-linear editing can cause modification in the original video whereas editing and re-edit and re-edit again can cause the video to be less true than the original material.

<h3>What is non-linear editing?</h3>

In non-linear editing, the editor can do any operation with the video like adding or removing any frame without starting from the beginning.

It's been characterized as a ‘cut and paste’ technique that can really innovate how video makers approach videography.

Therefore Non-linear editing can cause modification in the original video whereas editing and re-editing and re-editing again can cause the video to be less true than the original material.

To know more about non-linear editing follow

brainly.com/question/15614247

#SPJ4

8 0
2 years ago
Other questions:
  • If you are viewing a webpage with customized or regenerated content, such as updated stock quotes, what type of webpage are you
    14·1 answer
  • What outline feature can the Navigation pane browse the document by?
    14·2 answers
  • Write a program that reads the subtotal and the gratuity rate, then computes the gratuity and total. For example, if the user en
    6·1 answer
  • Hello can you please help with this if you want to thank you!
    15·2 answers
  • Can rank u r guys in rocket leagye
    13·1 answer
  • Create a statement that always returns the names of the three criminals with the highest number of crimes committed.
    15·1 answer
  • What is it important to test cabless?​
    7·1 answer
  • What is software??????​??????????????????
    7·2 answers
  • Where can i check on an acer chromebook to see what version of java is installed.
    13·1 answer
  • 4. //Program prompts users for names and quantities for a $2.00 product and displays total for each user until “XXX” is entered
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!