You have been given two classes, a Main.java and a Coin.java. The coin class represents a coin. Any object made from it will have a 1) name, 2) weight and 3) value. As of now, the instance variables in Coin.java are all public, and the main function is calling these variables directly for the one coin made in it.

Required:
Your goal is to enforce information hiding principles in this tasl. Take Coin.java, make all instance variables private and create set/get functions for each instance variable. Then replace the direct references in main() to each instance variable with a call to an appropriate set or get function.

Answers

Answer 1

Answer:

Here is the Coin class:

public class Coin {  //class names

 private int value;  // private member variable of type int of class Coin to store the value

 private String coinName;  // private member variable of type String of class Coin to store the coint name

 private double weight;      //private member variable of type double of class Coin to store the weight

  public void setValue (int v) {  //mutator method to set the value field

    value = v;  }  

     

 public void setName(String n){  //mutator method to set coinName field

    coinName = n;}  

 public void setWeight (double w) {  //mutator method to set weight field

    weight = w;  }  

 public int getValue () {  //accessor method to get the value

   return value;  }  // returns the current value

 

 public String getName () {  //accessor method to get the coin name

   return coinName;  }  //returns the current coin name

   

 public double getWeight () {   //accessor method to get the weight

   return weight;  } } //returns the current weight

 

Explanation:

Here is the Main.java

public class Main{ //class name

public static void main(String[] args) { //start of main method

Coin penny = new Coin(); //creates object of Coin class called penny

penny.setName("Penny");  //calls setName method of Coin using object penny to set the coinName to Penny

penny.setValue(1); //calls setValue method of Coin using object penny to set the coin value to 1

penny.setWeight(0.003); //calls setWeight method of Coin using object penny to set the coin weight to 0.003

   System.out.println("Coin name: " + penny.getName()); // calls getName method of Coin using penny object to get the current coin name stored in coinName field    

   System.out.println("Coin value: " + penny.getValue()); // calls getValue method of Coin using penny object to get the coin value stored in value field    

   System.out.println("Coin weight: " +penny.getWeight()); }} // calls getWeight method of Coin using penny object to get the coin weight stored in weight field    

The value of coinName is set to Penny, that of value is set to 1 and that of weight is set to 0.003 using mutator method and then the accessor methods to access these values and prinln() to display these accessed values on output screen. Hence the output of the entire program is:

Coin name: Penny                                                                                                                                Coin value: 1                                                                                                                                   Coin weight: 0.003

The screenshot of the program along with its output is attached.

You Have Been Given Two Classes, A Main.java And A Coin.java. The Coin Class Represents A Coin. Any Object

Related Questions

Jax needs to write a block of code that will organize a list of items alphabetically. Which function should he use? append() print() sort() order()

Answers

In python, the sort() function will alphabetically sort a list of strings

To write a block of code that will organize a list of items alphabetically  In python, the sort() function will alphabetically sort a list of strings.

What is python?

A high-level, all-purpose programming language is Python. Code readability is prioritized in its design philosophy, which makes heavy use of indentation. Python uses garbage collection and has dynamic typing. It supports a variety of paradigms for programming, including functional, object-oriented, and structured programming.

Python is a popular computer programming language used to create software and websites, automate processes, and analyze data. Python is a general-purpose language, which means it may be used to make many various types of applications and isn't tailored for any particular issues.

Sorting in Python simply means putting the data in a specific format or order. The order of the data pieces can be sorted either ascendingly or descendingly. Python programming contains certain built-in functions that allow you to sort the list's elements, just like C++ and Java.

Therefore, Thus option (C) is correct.

Learn more about python here:

https://brainly.com/question/18502436

#SPJ2

The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash are $1.25 with a gasoline purchase of $10.00 or more and $3.00 otherwise. Three kinds of gasoline are available: regular at $2.89, plus at $3.09, and super at $3.39 per gallon. User Request:
Write a program that prints a statement for a customer. Analysis:
Input consists of number of gallons purchased (R, P, S, or N for no purchase), and car wash desired (Y or N). Gasoline price should be program defined constant. Sample output for these data is
Enter number of gallons and press 9.7
Enter gas type (R, P, S, or N) and press R
Enter Y or N for car wash and press Y
**************************************
* *
* *
* Gas-N-Clean Service Station *
* *
* March 2, 2004 *
* * ************************************** Amount Gasoline purchases 9.7 Gallons Price pre gallons $ 2.89 Total gasoline cost $ 28.03 Car wash cost $ 1.25 Total due $ 29.28 Thank you for stopping Pleas come again Remember to buckle up and drive safely

Answers

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

              //print the header

              System.out.println("**************************************");

              System.out.println("*                                    *");

              System.out.println("*                                    *");

              System.out.println("*   Gas-N-Clean Service Station      *");

              System.out.println("*                                    *");

              System.out.println("*   March 2, 2004                    *");

              System.out.println("*                                    *");

              System.out.println("**************************************");

 

               //set the constant values for gasoline

               final double REGULAR_GASOLINE = 2.89;

               final double PLUS_GASOLINE = 3.09;

               final double SUPER_GASOLINE = 3.39;

 

              // initialize the variables as 0

              double gasolinePrice = 0, gasolineCost = 0, carWashCost = 0, totalCost = 0;

 

               Scanner input = new Scanner(System.in);

 

               //ask the user to enter the gallons, gas type and car wash choice

               System.out.print("Enter number of gallons ");

               double gasolinePurchase = input.nextDouble();

               System.out.print("Enter gas type (R, P, S, or N) ");

               char gasType = input.next().charAt(0);

               System.out.print("Enter Y or N for car wash ");

               char carWashChoice = input.next().charAt(0);

               //check the gas type. Depending on the choice set the gasolinePrice from the corresponding constant value

              if(gasType == 'R')

                  gasolinePrice = REGULAR_GASOLINE;

              else if(gasType == 'P')

                  gasolinePrice = PLUS_GASOLINE;

              else if(gasType == 'S')

                  gasolinePrice = SUPER_GASOLINE;

 

                //calculate the gasolineCost

                gasolineCost = gasolinePurchase * gasolinePrice;

 

               //check the carWashChoice. If it is yes and gasolineCost is greater than 10, set the carWashCost as 1.25. Otherwise, set the carWashCost as 3.00

               if(carWashChoice == 'Y'){    

                   if(gasolineCost >= 10)

                       carWashCost = 1.25;

                   else

                       carWashCost = 3.00;

               }

              //calculate the total cost, add gasolineCost and carWashCost

              totalCost = gasolineCost + carWashCost;

 

               //print the values in required format

              System.out.println("Amount Gasoline purchases " + gasolinePurchase);

              System.out.println("Gallons Price per gallons $ " + gasolinePrice);

              System.out.printf("Total gasoline cost $ %.2f\n", gasolineCost);

              System.out.println("Car wash cost $ " + carWashCost);

              System.out.printf("Total due $ %.2f\n", totalCost);

               System.out.println("Thank you for stopping\nPlease come again \nRemember to buckle up and drive safely");

}  

}

Explanation:

*The code is in Java.

Please see the comments in the code for explanation

A CPU with a quad-core microprocessor runs _____ times as fast as a computer with a single-core processor.

two

three

four

eight

Answers

Four is the rught answer i don’t think so

Answer:

four

Explanation:

quad means four so it runs four times faster

How can you create an illusion of spatial depth in a two-dimensional design?

Answers

Answer:

Using three or more vanishing points within a work to create the illusion of space on a two-dimensional surface.

Explanation:

create a boolean variable called sucess that will be true if a number is between -10 and 10 inclusively python

Answers

Answer:

success = -10 <= number <= 10

Explanation:

I check that -10 is less than or equal to number, and number is less than or equal to 10.

Plz answer me will mark as brainliest ​

Answers

1 plus 1 is too and three to four is 111

what is 9x9x9? pls help

Answers

Answer:

729. is answer...........

Answer:

729

Explanation:

According to Darwin’s theory of evolution, differences between species may be a result of which of the following?
a) The disuse of body structures
b) The transmission of acquired characteristics
c) Natural selection
d) Mutagenic agents

Answers

Answer:

The answer is C Natural selection

Explanation:

Natural selection is the differential survival and reproduction of individuals due to differences in phenotype. It is a key mechanism of evolution, the change in the heritable traits characteristic of a population over generations

According to Darwin’s theory of evolution, differences between species may be a result of  Natural selection. Thus the correct option is C.

What is  Darwin’s theory of evolution?

According to Darwin, all species descended from a single ancestor, species can change through time, and new species can arise from existing ones which makes them interconnected with common traits.

Natural selection of traits in a species that would help the species in its survival is the process that drives diversification, the evolutionary process through which new biological species form.

Natural selection is the evolutionary mechanism stating that with many resources available in nature, creatures with genetically inherited features that promote survival and reproduction will typically produce more offspring than their conspecific competitors.

Therefore, option C is appropriate.

Learn more about  Darwin’s theory of evolution, here:

https://brainly.com/question/25718754

#SPJ6

Which type of chart or graph uses vertical bars to compare data?

Column chart
Line graph
Pie chart
Scatter chart

Answers

Answer:

Colunm Chart

Explanation:

Trust me

What is the process to add images to your library panel in Adobe Animate CC?
Answer choices
Choose file>import>import library
Choose file>open>insert image
Choose file>export>export file
Choose file> New> file

Answers

Answer:

Choose file>import>import library

Explanation:

because it is the process to add images to your library

Challenge activity 1.3.6:output basics.for activities with output like below,your output's whitespace(newlines or spaces) must match exactly.see this note.write code that outputs the following.end with a newline.This weekend will be nice.​

Answers

In python:

print("This weekend will be nice.")

I hope this helps!

If you want Nud3s add me on sc Kermit4lyfe1

Answers

Answer:

que pinga this is a hw website not snap

Explanation:

bro are you okay umm

7. While an adjacency matrix is typically easier to code than an adjacency list, it is not always a better solution. Explain when an adjacency list is a clear winner in the efficiency of your algorithm

Answers

Answer:

The answer is below

Explanation:

Adjacency list is a technique in a computer science that is used for representing graph. It deals with a gathering of unorganized lists utilized to illustrate a limited graph. In this method, each list depicts the group of data of a peak in the graph

Adjacency List are most preferred to Adjacency Matrix in some cases which are:

1.  When the graph to is required to be sparsely.

2.  For iterability, Adjacent List is more preferable

Need help with coding.
I'm trying to input a list that uses int(input("Element: ")) and it's causing an error. Anything to help with this?

Answers

You could try something likes this.

lst = []

n = int(input("Number of elements: ))

for i in range(0, n):

element = int(input("Element: "))

lst.append(element)

To use cout statements you must include the __________ file in your program.

Answers

Answer:

To use cout statements, you must include the iostream file in your program.

describe how to get started on a formal business document by using word processing software

Answers

Answer:Click the Microsoft Office button.

Select New. The New Document dialog box appears.

Select Blank document under the Blank and recent section. It will be highlighted by default.

Click Create. A new blank document appears in the Word window.

Explanation:

Which of the following is NOT solely an Internet-based company?
Netflix®
Amazon®
Pandora®
CNN®

Answers

Answer:

I think it's Pandora, though I am familiar with others

Answer:

CNN

Explanation:

Return to the Product Mix worksheet. Benicio wants to provide a visual way to compare the scenarios. Use the Scenario Manager as follows to create a PivotTable that compares the profit per unit in each scenario as follows:
a. Create a Scenario PivotTable report using the profit per unit sold (range B17:F17) as the result cells.
b. Remove the Filter field from the PivotTable.
c. Change the number format of the value fields to Currency with 2 decimal places and the $ symbol.

Answers

Answer:

To create a pivot table, select the columns to pivot and click on the insert option, click on the pivot table option and select the data columns for the pivot, verify the table range, select the location for the pivot and click ok. To format a column, select the columns and click the number option on the home tab, select the currency option and click on the number of decimal places

Explanation:

Microsoft Excel is a great tool for data analysis and visualization. It has several mathematical, engineering, statistical, and graphical tools for working with data.

A pivot-table is an essential tool for describing and comparing data of different types.

The steps to follow in order to produce a Pivot table would be as mentioned below:

Opting the columns for a pivot table. Now, make a click on the insert option. This click is followed by opting for the pivot table and the data columns that are available in it.After this, the verification of the range of the table is made and then, the location for the pivot table has opted. After this, the column is formatted and the number option is selected followed by the currency option, and the quantity of decimal places. A Pivot table allows one to establish a comparison between data of distinct categories(graphic, statistical, mathematical) and elaborate them.

Learn more about 'Pivot Table' here:

brainly.com/question/13298479

Write a program whose inputs are three integers, and whose output is the smallest of the three values. Use else-if selection and comparative operators such as '<=' or '>=' to evaluate the number that is the smallest value. If one or more values are the same and the lowest value your program should be able to report the lowest value correctly. Don't forget to first scanf in the users input.

Ex: If the input is: 7 15 3
the output is: 3

You should sketch out a simple flowchart to help you understand the conditions and the evaluations needed to determine what number is the correct answer. This type of tool can help determine flaws in a logical design.

Answers

Answer:

The Program written in C is as follows:

#include <stdio.h>

int main() {

   int num1, num2, num3, smallest;

   printf("Enter any three numbers: ");

   scanf("%d", &num1);    scanf("%d", &num2);    scanf("%d", &num3);

   if(num1 <= num2 && num1 <= num3) {

       smallest = num1;

   }

   else if(num2 <= num1 && num2 <= num3) {

       smallest = num2;

   }

   else {

       smallest = num3;

   }

   printf("Smallest: ");

   printf("%d", num3);

   return 0;

}

Explanation:

This line declares necessary variables

int num1, num2, num3, smallest;

This line prompts user for input of three numbers

   printf("Enter any three numbers: ");

This lines get input for the three numbers

   scanf("%d", &num1);    scanf("%d", &num2);    scanf("%d", &num3);

The following if/else statements determine the smallest of num1, num2 and num3 and assigns to variable smallest, afterwards

   if(num1 <= num2 && num1 <= num3) {

       smallest = num1;

   }

   else if(num2 <= num1 && num2 <= num3) {

       smallest = num2;

   }

   else {

       smallest = num3;

   }

The next two lines print the smallest value

   printf("Smallest: ");

   printf("%d", num3);

A have a string, called "joshs_diary", that is huge (there was a lot of drama in middle school). But I don't want every one to know that this string is my diary. However, I also don't want to make copies of it (because my computer doesn't have enough memory). Which of the following lines will let me access this string via a new name, but without making any copies?

a. std::string book = joshs_diary;
b. std::string & book = joshs_diary; const
c. std::string * book = &joshs_diary;
d. std::string book(joshs_diary);
e. const std::string & book = joshs_diary;
f. const std::string * const book = &joshs_diary;
g. std::string * book = &joshs_diary;

Answers

Answer:

C and G

Explanation:

In C language, the asterisks, ' * ', and the ampersand, ' & ', are used to create pointers and references to pointers respectively. The asterisks are used with unique identifiers to declare a pointer to a variable location in memory, while the ampersand is always placed before a variable name as an r_value to the pointer declared.

Jake or Peggy Zale must fix quickly the fax.

Answers

Answer:

Sentence: Jack or Peggy Zale must fix quickly the fax.

Correct: Either Jack or Peggy Zale must quickly fix the fax.

There are 2 errors in these sentence construction. In stating two persons as an option we must use the word "either" to indicate that you only have two choose from the two of them. The word "

Explanation:

The correct sentence would be "either Jake or Peggy Zale must quickly fix the fax".

In the question construction, there is a conjunction and misarrangement error.

In conclusion, the word " "either Jake or Peggy Zale must quickly fix the fax" is correct

Read more about conjunction

brainly.com/question/8094735

In Python
Write the special method __str__() for CarRecord.

Sample output with input: 2009 'ABC321'
Year: 2009, VIN: ABC321

Answers

Answer:

def __str__(self):

       return ('Year: %d, VIN: %s' %(self.year_made, self.car_vin))

Explanation:

Here you go! This should do it.

The program gives an implementation of the car record class which displays the model year and registration number of a car. The program written in python 3 goes thus :

class CarRecord :

#initialize a class named carRecord

def __init__(self):

#define the init method of the class

self.year_made = 0

#year car was made is initialized to 0 (integer)

self.car_vin = ' '

#vehicle registration is an empty string

def __str__(self):

#define an str method

return f"Year:{self.year_made}, VIN:{self.car_vin}"

#returns formatted display of the year and VIN number

my_car = CarRecord()

#creates an instance of the carRecord class

my_car.year_made = int(input())

#prompts user for the model year of the car

my_car.car_vin = input()

#prompts user for the model Vin number

print(my_car)

# display the details

A sample run of the program is given

Learn more :https://brainly.com/question/20504501

Who is a software engineer

Answers

A person who applies principles of software engineering to the design
Hope this helps !

Write code that Uses the range() in a for loop to iterate over the positions in user_names in order to modify the list g

Answers

Answer:

Explanation:

The range() function is a built-in function in the Python programming language. In the following code, we will use this function to iterate over all the positions in the array called user_names and add them to the list g. (assuming that is what was meant by modifying the list g)

for i in range( len(user_names) ):

   g.append(user_names[i])

This simple 2 line code should do what you are asking for.

How has the rise of mobile development and devices impacted the IT industry, IT professionals, and software development

Answers

Answer:

Throughout the interpretation section elsewhere here, the explanation of the problem is summarized.

Explanation:

The growth of smartphone production and smartphone apps and services, as well as the production of smartphones, has had a positive influence on the IT industry, IT practitioners, as well as the development of the technology. As normal, the primary focus is on smartphone apps instead of just desktop software. As we recognize, with innovative features, phone applications, and smartphones are all made, built, modernized every day, and always incorporated with either the latest technology.This has now resulted in far more jobs and employment for the IT sector, and therefore new clients for service-based businesses. It provided various-skilling the application production industry for IT experts including learning how to work on emerging technology. The demand for software production and software growth is evolving at a greater speed than it's ever been, so the increase of smartphone production and smartphones has had a very beneficial effect on perhaps the IT sector, IT practitioners, and business development.

Kara's teacher asked her to create a chart with horizontal bars. Which chart or graph should she use?

Bar graph
Column chart
Line graph
Pie chart

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct answer to this question is the Bar graph.

Because we use this chart type to visually compare values across a few categories when the charts show duration or when the category text is long.

However, we can present information similarly in the bar graph and in column charts, but if you want to create a chart with the horizontal bar then you must use the Bar graph. In an Excel sheet, you can easily draw a bar graph and can format the bar graph into a 2-d bar and 3-d bar chart.

A column chart is used to compare values across a few categories. You can present values in columns and into vertical bars.

A line graph chart is used to show trends over months, years, and decades, etc.

Pie Chart is used to show a proportion of a whole. You can use the Pie chart when the total of your numbers is 100%.

Answer:

Bar graph option A

Explanation:

I did the test

Which part of the formula is the argument?

=COUNTIF(A1:E59, "Greene City")

=

()

COUNTIF

A1:E59

Answers

Answer:

e on edege

Explanation:

just took the question on edge

Answer:

Guy above is right!

Explanation:

Write a program which:

Allows the user to input any of the following string: A1, A2, B1, B2, C1, C2

If the input is from the A category, the program must output "Footwear: ". And if the input is A1 it should output "Shoes" and if A2 it should output "Trainers"

B should output "Tops: "

B1 "Jackets"

B2 "TShirts"

C "Pants: "

C1 "Trousers"

C2 "Shorts"

If the user has not entered the correct data, the program must output "Incorrect input"

Answers

Answer:

Ill do this in C# and Java

Explanation:

C#:

public static void Main(string[] args)

       {

           string input = Console.ReadLine();

               switch (input)

               {

                   case "A1":

                       Console.WriteLine("Footwear:");

                       Console.WriteLine("Shoes");

                       break;

                   case "B1":

                       Console.WriteLine("Tops:");

                       Console.WriteLine("Jackets");

                       break;

                   case "C1":

                       Console.WriteLine("Pants:");

                       Console.WriteLine("Trousers");

                       break;

                   case "A2":

                       Console.WriteLine("Footwear:");

                       Console.WriteLine("Trainers");

                       break;

                   case "B2":

                       Console.WriteLine("Tops:");

                       Console.WriteLine("TShirts");

                       break;

                   case "C2":

                       Console.WriteLine("Pants:");

                       Console.WriteLine("Shorts");

                       break;

                   default:

                       Console.WriteLine("Incorrect Input");

                       break;

               }

       }

Java:

public static void main(String[] args)

   {

       Scanner myObj = new Scanner(System.in);  // Create a Scanner object

       String input = myObj.nextLine();

       {

           switch (input)

               {

                   case "A1":

                       System.out.println("Footwear:");

                       System.out.println("Shoes");

                       break;

                   case "B1":

                       System.out.println("Tops:");

                       System.out.println("Jackets");

                       break;

                   case "C1":

                       System.out.println("Pants:");

                       System.out.println("Trousers");

                       break;

                   case "A2":

                       System.out.println("Footwear:");

                       System.out.println("Trainers");

                       break;

                   case "B2":

                       System.out.println("Tops:");

                       System.out.println("TShirts");

                       break;

                   case "C2":

                       System.out.println("Pants:");

                       System.out.println("Shorts");

                       break;

                   default:

                       System.out.println("Incorrect Input");

                       break;

               }

       }

What does GDF is a measure of a nations?

Answers

I’m confused on the question can you rephrase that

Data Structure in C++
Using namespace std;
In this assignment you will implement a variation of Mergesort known as a bitonic mergesort, recursively.
In a normal mergesort, the input to the merge step is a single array, which is divided into two sections, both sorted ascending. We assume that the first half (0 up to but not including size/2) is the first section and the second half (size/2 up to but not including size) is the second section.
In a bitonic mergesort, we use the same arrangement, except that the second sequence is sorted in descending order: the first half goes up, and then the second half goes down. This means that when we are doing a merge, sometimes we want to merge the results into ascending order, while other times we want to merge into descending order (depending on which "half" of the final array the result will end up in). So we add another parameter, to describe the direction the output should be sorted into:
void merge(int* input, int size, int* output, bool output_asc);
If output_asc == true then after the merge output should contain size elements, sorted in ascending order. If output_asc == false, output should contain the elements sorted in descending order.
The other thing we glossed over in class was the allocation of the temporary space needed by the algorithm. It’s quite wasteful to allocate it in each recursive call: it would be better to allocate all the necessary space up front, and then just pass a pointer to it. In order to do this, we’ll write the recursive mergesort function in a helper function which will preallocate the space needed for the results:
int* mergesort(int* input, int size) {
int* output = new int[size];
mergesort(input, size, output, true);
return output;
}
void mergesort(int *input, int size, int* output, bool output_asc) {
// Your implementation here
}
The parameter output_asc serves the same purpose here as for merge: it tells the function that we want the output to be sorted ascending.
Interface
You must implement the functions
void merge(int* input, int size, int* output, bool output_asc);
int* mergesort(int* input, int size);
void mergesort(int *input, int size, int* output, bool output_asc);
Download a template .cpp file containing these definitions. This file is also available on the server in /usr/local/class/src.
merge must run in O(n) time with n= size. mergesort (both versions) must run in O(nlogn) time, and must use O(n) space. If you allocate any space other than the output array, you should free it before your function returns.
The test runner will test each function separately, and then in combination. It checks the result of sorting to make sure that it’s actually sorted, and then nothing is missing or added from the original (unsorted) sequence.

Answers

The code .cpp is available bellow

#include<iostream>

using namespace std;

//declaring variables

void merge(int* ip, int sz, int* opt, bool opt_asc); //merging

int* mergesort(int* ip, int sz);

void mergesort(int *ip, int sz, int* opt, bool opt_asc);

void merge(int* ip, int sz, int* opt, bool opt_asc)

{

  int s1 = 0;

  int mid_sz = sz / 2;

  int s2 = mid_sz;

  int e2 = sz;

  int s3 = 0;

  int end3 = sz;

  int i, j;

   

  if (opt_asc==true)

  {

      i = s1;

      j = e2 - 1;

      while (i < mid_sz && j >= s2)

      {

          if (*(ip + i) > *(ip + j))

          {

              *(opt + s3) = *(ip + j);

              s3++;

              j--;

          }

          else if (*(ip + i) <= *(ip + j))

          {

              *(opt + s3) = *(ip + i);

              s3++;

              i++;

          }

      }

      if (i != mid_sz)

      {

          while (i < mid_sz)

          {

              *(opt + s3) = *(ip + i);

              s3++;

              i++;

          }

      }

      if (j >= s2)

      {

          while (j >= s2)

          {

              *(opt + s3) = *(ip + j);

              s3++;

              j--;

          }

      }

  }

  else

  {

      i = mid_sz - 1;

      j = s2;

      while (i >= s1 && j <e2)

      {

          if (*(ip + i) > *(ip + j))

          {

              *(opt + s3) = *(ip + i);

              s3++;

              i--;

          }

          else if (*(ip + i) <= *(ip + j))

          {

              *(opt + s3) = *(ip + j);

              s3++;

              j++;

          }

      }

      if (i >= s1)

      {

          while (i >= s1)

          {

              *(opt + s3) = *(ip + i);

              s3++;

              i--;

          }

      }

      if (j != e2)

      {

          while (j < e2)

          {

              *(opt + s3) = *(ip + j);

              s3++;

              j++;

          }

      }

  }

   

  for (i = 0; i < sz; i++)

      *(ip + i) = *(opt + i);

}

int* mergesort(int* ip, int sz)

{

  int* opt = new int[sz];

   

  mergesort(ip, sz, opt, true);

  return opt;

}

void mergesort(int *ip, int sz, int* opt, bool opt_asc)

{

  if (sz > 1)

  {

      int q = sz / 2;

      mergesort(ip, sz / 2, opt, true);

      mergesort(ip + sz / 2, sz - sz / 2, opt + sz / 2, false);

      merge(ip, sz, opt, opt_asc);

  }

}

int main()

{

  int arr1[12] = { 5, 6, 9, 8,25,36, 3, 2, 5, 16, 87, 12 };

  int arr2[14] = { 2, 3, 4, 5, 1, 20,15,30, 2, 3, 4, 6, 9,12 };

  int arr3[10] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };

  int *opt;

  cout << "Arays after sorting:\n";

  cout << "Array 1 : ";

  opt = mergesort(arr1, 12);

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

      cout << opt[i] << " ";

  cout << endl;

  cout << "Array 2 : ";

  opt = mergesort(arr2, 14);

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

      cout << opt[i] << " ";

  cout << endl;

  cout << "Array 3 : ";

  opt = mergesort(arr3, 10);

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

      cout << opt[i] << " ";

  cout << endl;

  return 0;

}

Other Questions
All _______________ as we know it on Earth is dependent on __________________. Redacta en un prrafo de cinco lneas un argumento a favor o en contra de las acciones realizadas por la joven prometida. La obra se llama "Bodas de Sangre". what negative angle is equivalent to a 75 angle what were denis diderots thoughts on government Assume that Ray is 38 years old and has 27 years for saving until he retires. He expects an APR of 7.5% on his investments. How much does he need to save if he puts money away annually in equal end-of-the-year amounts to achieve a future value of $1,200,000 dollars in 27 years' time David is completing a word list with words from this paragraph.We enjoyed all types of travel during our family vacation to Italy. First we took a train to get into the city. Later we rented bikes to explore the mountain trails. Finally, we enjoyed floating along the water in a real Italian gondola! A 4-column table with 3 rows. Column 1 is labeled Word with entries train, bike, gondola. Column 2 is labeled Part of speech with entries noun, noun, noun. Column 2 is labeled Example sentence with entries "First we took a train to get into the city," "Later we rented bikes to explore the mountain trails," "Finally, we enjoyed floating along the water in a real Italian gondola!" Column 4 is labeled Meaning with entries a rolling group of cars, a two-wheeled vehicle, blank.What is the meaning of the word gondola?a three-wheeled vehiclea long, narrow boatan extra-long busan underground train which gas is not abundant in earth's atmosphere?a. oxygenb. hydrogenc. nitrogend. argon You have started your own online business selling dvds. You sell twenty four DVDs per week online. How many DVDs do you sell in six weeks? PLSSS HELP ME I WILL MARK U!!!!!!! Please, I need help!The table above shows the number of trees and the number of apples that Jacob picked from each tree. Answer the following questions based on he table above1. How many apples will Jacob pick from one tree. (calculate the unit rate).2.Is there a proportional relationship between the number of trees and the number of apples Jacob picked? Explain using mathematical reasoning.3. Using the unit rate, write an equation that Jacob can use to calculate how many apples he is able to pick from any tree.4. Using your equation if Jacob had 25 trees, how many apples will he have. Which statement correctly explains tribal governments in Arizona?Tribes dont follow the US example of the three-branch model.Each tribe has its own government and makes its own laws.The tribes are dependent on the state government for money.The tribes are all totally exempt from federal and state laws. The temperature at 8 p.m. was 6 degrees. at 2 p.m. the temperature decreased 13 degrees. What was the temperature at 2 a.m.? Fish Cheeks what was the problem in the sotry Differentiate qualitative from qualitative observation Carlos es _____ amigo sincero. a. unb. unos What two meanings of friendship are presented will give brainliest Next, choose one of the three diary entries that youve written and examine the entry for the elements of purpose and point of view.Make a list of these elements for your diary entry and then define each element and any unclear terms or phrases.the things i wrote-One of my biggest pet peeves is tapping your foot, its so annoying and makes me want to scream. it also makes me unfocus because of the fact that it shakes the floor. Once i realize youre tapping your foot i keep focusing on you tapping and sometimes it makes me cry because of how annoying it is. It can also be very loud and obnoxious. but it could also be how that person fidgets, manages stress, thinks, etc any tragedy becomes a humour after a certain period of time and we start enjoying our worst tradgedy, what a moment it is! Humor is the only thing that helps us to cope with all our stress and worries. People always try to make their tragedy into a comedy. After the passage of time they change their mind set towards their old tragedies. example from my life, : me and my sister and cousins went to a pool and after we got done my aunt arden was put into a hospital on her death bed.i normally feel invisable when i try and speak to my family, they dont ever answer me and i have to repeat myself over and over again until someone hears me. I stay in my room all day unless i have to come out. my dad yells alot and i get introuble alot so i try and stay away from everyone unless i have to come out of my room. The only time someone cares is when im crying. Strangers on the internet and my friends back in Brewton AL make me feel more loved than my own family in general How Does EnvironmentImpact CultUre? What role did trading play in both New Netherland and New Sweden? What value is missing from the table?