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
kotykmax [81]
4 years ago
12

write a function issorted() that accepts an array of real numbers arr and an integer n as arguments, where n is the size of arr.

The function properly reads n integers into the array arr,then finds and returns whether the items of the array are sorted in ascending order.
Computers and Technology
1 answer:
lesantik [10]4 years ago
7 0

Answer:

Here is code in java.

import java.util.*;

class Main

{

//main method of the class

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

{

   try{

       int m;

        // scanner object to read input from user

       Scanner ss=new Scanner(System.in);

       System.out.println(" size  of the array:");

       //read the size of the array

        m=ss.nextInt();

        // create array of the given size

        float arr[]=new float[m];

        /* call function to check whether input are in the ascending sorted order or not */

        Boolean res= issorted(arr,m);

       

      // print the result

       System.out.println("array in the ascending sorted order  : "+res);

     

       

   }catch(Exception ex){

       return;}

}

 // function to check whether input are in the ascending sorted order or not

public static boolean issorted(float[] arr,int n)

{

    int i,j;

    float d;

    Boolean flag=true;

    Scanner ss=new Scanner(System.in);

    System.out.println("enter the elements of the array:");

     // read elements of the array

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

    {

        arr[i]=ss.nextFloat();

    }

   

    // check elements re in the ascending order or not

    for(j=0;j<n-1;j++)

    {

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

        {

            flag=false;

            break;

        }

    }

     // return the result

    return flag;

}

}

Explanation:

With the help of scanner class object, read the size "m" of array.Create an array of  the given size. Pass array and integer into the function issorted(). Read the elements of the array and then check elements are in the ascending order or not.It will return "true" if elements are in the sorted order else it will return "false".

Output:

enter  size  of the array:                                                                                                                                    

5                                                                                                                                                              

enter the elements of the array:                                                                                                                              

1 2 3 4 7                                                                                                                                                      

array in the ascending sorted order  : true                                                                                                                              

enter  size  of the array:                                                  

5                                                                            

enter the elements of the array:                                              

2 4 9 3 5                                                                  

array in the ascending sorted order  : false

You might be interested in
What tasks do data entry macros commonly perform? Check all that apply.
Paha777 [63]

Answer:

test whether a user entered a value

3 0
3 years ago
Can someone help me on drawing ER and Use case diagram on following scenarios. ASAP!!! Please :(
GalinKa [24]

Answer:

The ER Diagram is in the attachment. And I an including the membership details in the use case:

Applicants: Coach will ask for iD.

if the application is not registered, coach sends to registration department.

Applicants registers-->> shows registration ID-->> goes to account section

Submits the fee->> goes to coach again-->>coach asks for fee sjip-->> On yes-->> entrance allowed else-->> sent to account section

Applicants apply for course-->>if prerequisite is met, registration allowed

else-->>registration denied

Note: If registration is allowed the applicant is sent to account section and

Also note:

First check, then registration, then course prerequisite check,then account->entrance

If registered->direct entry.

Explanation:

The answer is self explanatory.

4 0
4 years ago
Write a program with total change amount as an integer input that outputs the change using the fewest coins, one coin type per l
alexandr1967 [171]

Answer:

a=input("Amount in pennies")

b=int(a)

dollars=0

dimes= 0

quarters=0

nickels=0

pennies = 0

dollars = int(b/100)

b= b- dollars *100

quarters=int(b/25)

b=b-quarters*25

dimes = int(b/10)

b = b -dimes*10

nickels=int(b/5)

b=b - nickels * 5

pennies = b

print(dollars)

print(dimes)

print(nickels)

print(pennies)

Explanation:

The required program is in answer section. Note, the amount is entered in pennies.

7 0
3 years ago
The M:N relationship between STUDENT and CLASS must be divided into two 1:M relationships through the use of the ENROLL entity;
zubka84 [21]

Answer:

The answer is "weak".

Explanation:

In the given statement some option is missing which can be described as follows:

A) weak  

B) strong  

C) optional

D) mandatory

The weak entity is an object, which could not be described specifically by its properties only, It should have a foreign key to create a primary key in comparison to its attributes, and wrong choices can be explained as follows:

  • In option B, It describes the relationship with the weak entities.
  • In option C, It describes the relationship, which is not necessary.
  • In option D, In every case, an entity could be affiliated with another entity, but this is not necessary.
3 0
3 years ago
Read 2 more answers
What are the three most important tasks accomplished at a party’s national convention are nominating the party’s?
Elenna [48]

The  three most important tasks are:

  • The selection and naming the party's presidential and vice-presidential candidates
  • The act of promoting party unity
  • The  adopting of the party's platform.

<h3>What is the task of a national convention?</h3>

The formal aim of such a convention is to take the party's nominee for any popular election such as the President and also to adopt a idea of party principles and goals.

Hence, the  three most important tasks are:

  • The selection and naming the party's presidential and vice-presidential candidates
  • The act of promoting party unity
  • The  adopting of the party's platform.

Learn more about  national convention from

brainly.com/question/2199497

#SPJ1

8 0
2 years ago
Other questions:
  • Which of the following is not a standard method called as partof the JSP life cycle?
    5·1 answer
  • A data center designer requested additional lighting for the entrance to the data center as well as the removal of a object whic
    11·1 answer
  • You can access your programs, your documents, your printer, even help from
    15·2 answers
  • George has to develop a website for his dad’s cycle shop. He wants to focus mainly on the products and wants the website to have
    10·1 answer
  • What runs horizontally and is identified with numbers?
    12·2 answers
  • What is the full form of PDP​
    7·1 answer
  • Consider a Games Expo for Children. Six competitions are laid out for the expo. Tickets are sold according to the age and gender
    11·1 answer
  • Burtex Inc. is an application development organization. Twenty five of its knowledgeable employees are retiring in the upcoming
    6·1 answer
  • _ is a term used for license like those issues by creative commons license as an alternative to copyright
    8·1 answer
  • Assume you have a button control named btndisplaylist. Which is the default name for an event procedure that will be executed wh
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!