Skip to main content

Designed a class SortData that contains the method asec() and desc(). | VCMIT

The Method asec() And desc().



INPUT

import java.util.*;
class prac4A
{
Scanner input=new Scanner(System.in);
int num,i;
int arr[];
int temp=0;
public void getdata()
{
System.out.print("Enter the size of array: ");
num=input.nextInt();
arr=new int[num];
System.out.print("Enter the number: ");
for( i=0;i<num;i++)
{
arr[i]=input.nextInt();
}
}
void putdata()
{
System.out.print("Given numbers are: ");
for(i=0;i<num;i++)
{
System.out.println(arr[i]);
}
}
void asce()
{
for(i=0;i<num;i++)
{
for(int j=i+1;j<num;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
System.out.print("Ascending order of number are: ");
for(int i=0;i<num;i++)
{
System.out.println(arr[i]);
}
}
void desc()
{
for(i=0;i<num;i++)
{
for(int j=i+1;j<num;j++)
{
if(arr[i]<arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
System.out.print("Descending order of number are: ");
for(int i=0;i<num;i++)
{
System.out.println(arr[i]);
}
}
public static void main(String args[])
{
prac4A ob=new prac4A();
ob.getdata();
ob.putdata();
ob.asce();
ob.desc();
}
}

OUTPUT



Comments

Popular posts from this blog

Create House Like Structure Perform Operations Program In C | VCMIT

Program to create a house like figure and perform the following operations.  Scaling about the origin followed by translation.  Scaling with reference to an arbitrary point. Reflect about the line y = mx + c. INPUT #include <stdio.h> #include <graphics.h> #include <stdlib.h> #include <math.h> #include <conio.h> void reset (int h[][2]) { int val[9][2] = { { 50, 50 },{ 75, 50 },{ 75, 75 },{ 100, 75 }, { 100, 50 },{ 125, 50 },{ 125, 100 },{ 87, 125 },{ 50, 100 } }; int i; for (i=0; i<9; i++) { h[i][0] = val[i][0]-50; h[i][1] = val[i][1]-50; } } void draw (int h[][2]) { int i; setlinestyle (DOTTED_LINE, 0, 1); line (320, 0, 320, 480); line (0, 240, 640, 240); setlinestyle (SOLID_LINE, 0, 1); for (i=0; i<8; i++) line (320+h[i][0], 240-h[i][1], 320+h[i+1][0], 240-h[i+1][1]); line (320+h[0][0], 240-h[0][1], 320+h[8][0], 240-h[8][1]); } void rotate (int h[][2], float angle) { int i; for (i=0; i<9; i++) { int xnew, ynew; xnew = h[i][0] * cos (angle) - h[i]

Software Engineering - Waterfall Model | VCMIT

Waterfall model Winston Royce introduced the Waterfall Model in 1970.This model has five phases: Requirements analysis and specification, design, implementation, and unit testing, integration and system testing, and operation and maintenance. The steps always follow in this order and do not overlap. The developer must complete every phase before the next phase begins. This model is named "Waterfall Model", because its diagrammatic representation resembles a cascade of waterfalls. 1. Requirements analysis and specification phase: The aim of this phase is to understand the exact requirements of the customer and to document them properly. Both the customer and the software developer work together so as to document all the functions, performance, and interfacing requirement of the software. It describes the "what" of the system to be produced and not "how."In this phase, a large document called Software Requirement Specification (SRS) document is created whic

What Is Software? | VCMIT

Software Software is a set of instructions, data or programs used to operate computers and execute specific tasks. Opposite of hardware, which describes the physical aspects of a computer, software is a generic term used to refer to applications, scripts and programs that run on a device. Software can be thought of as the variable part of a computer, and hardware the invariable part. Software is often divided into categories. Application software refers to user-downloaded programs that fulfill a want or need. Examples of applications include office suites, database programs, web browsers, word processors, software development tools, image editors and communication platforms. System software includes operating systems and any program that supports application software.