Question about Microsoft Computers & Internet

# Simple java program for sorting numbers

I need a simple java programProgram should input a number n.
Take n integers.
and then output the sorted array.
(Use any sorting algorithm)

Posted by on

• Level 1:

An expert who has achieved level 1.

• Contributor

2007 office downlods software help

Posted on Jun 01, 2009

Hi there,
Save hours of searching online or wasting money on unnecessary repairs by talking to a 6YA Expert who can help you resolve this issue over the phone in a minute or two.

Best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.

Here's a link to this great service

Good luck!

Posted on Jan 02, 2017

×

my-video-file.mp4

×

## Related Questions:

### Wirte a pogram in java using for loop,that will print out the first 1 numbers of a fibonacii series that is:1 1 2 3 5 13 21 34 55

package com.gpt;

import javax.swing.JOptionPane;

/*
This program computes Fibonacci numbers using a recursive
method.
*/
public class Fibonacci
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog("Enter n: ");
int n = Integer.parseInt(input);

for (int i = 1; i {
int f = fib(i);
System.out.println("fib(" + i + ") = " + f);
}
System.exit(0);

}

/**
Computes a Fibonacci number.
@param n an integer
@return the nth Fibonacci number
*/
public static int fib(int n)
{
if (n return 1;
else
return fib(n - 1) + fib(n - 2);
}
}

Feb 24, 2011 | Sun Java Programming Language (cdj-275)

### I need a complete workingsource code written in

This is a simple source code for Simple calculator in Java using RMI
//mathServer//
import java.rmi.*;
import java.rmi.Naming.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.net.*;
import java.util.*;
interface mathInterface extends Remote
{
public int add(int a,int b) throws RemoteException;
public int subt(int a,int b) throws RemoteException;
public int mult(int a,int b) throws RemoteException;
public int div(int a,int b) throws RemoteException;
}
public class mathServer extends UnicastRemoteObject implements
mathInterface
{
public mathServer() throws RemoteException
{
System.out.println("Initializing Server");
}
{
return(a+b);
}
public int subt(int a,int b)
{
return(a-b);
}
public int mult(int a,int b)
{
return(a*b);
}
public int div(int a,int b)
{
return(a/b);
}
public static void main(String args[])
{
try
{
mathServer ms=new mathServer();
java.rmi.Naming.rebind("MathServ",ms);
}
catch(RemoteException RE)
{
System.out.println("Remote Server Error:"+ RE.getMessage());
System.exit(0);
}
catch(MalformedURLException ME)
{
System.out.println("Invalid URL!!");
}
}
}

//mathClient//
import java.rmi.*;
import java.rmi.registry.*;
import java.awt.*;
import java.awt.event.*;
public class mathClient extends Frame implements ActionListener
{
Button B1=new Button("Sum");
Button B2=new Button("Subtract");
Button B3=new Button("Multiply");
Button B4=new Button("Divide");
Label l1=new Label("Number 1");
Label l2=new Label("Number 2");
Label l3=new Label("Result");
TextField t1=new TextField(20);
TextField t2=new TextField(20);
TextField t3=new TextField(20);
public mathClient()
{
super("Calculator");
setLayout(null);
l1.setBounds(20,50,55,25);
l2.setBounds(20,100,55,25);
l3.setBounds(20,150,55,25);
t1.setBounds(150,50,100,25);
t2.setBounds(150,100,100,25);
t3.setBounds(150,150,100,25);
B1.setBounds(20,200,80,25);
B2.setBounds(100,200,80,25);
B3.setBounds(180,200,80,25);
B4.setBounds(260,200,80,25);
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
);
}
public void actionPerformed(ActionEvent AE)
{
if(AE.getSource()==B1)
{
sum();
}
else if(AE.getSource()==B2)
{
subt();
}
else if(AE.getSource()==B3)
{
mult();
}
else if(AE.getSource()==B4)
{
div();
}
}
public void sum()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void subt()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.subt(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void mult()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.mult(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public void div()
{
int i=Integer.parseInt(t1.getText());
int j=Integer.parseInt(t2.getText());
int val;
try
{
String ServerURL="MathServ";
mathInterface MI=(mathInterface)Naming.lookup(ServerURL);
val=MI.div(i,j);
t3.setText(""+val);
}
catch(Exception ex)
{
System.out.println("Exception:"+ex);
}
}
public static void main(String args[])
{
mathClient MC=new mathClient();
MC.setVisible(true);
MC.setSize(600,500);
};
}

Jul 03, 2009 | Microsoft Computers & Internet

### HOW TO SORT THE NUMBERS IN JAVA

Mar 04, 2009 | Computers & Internet

### May problem is "inputting four numbers and get the minimum number of them, and would be outputting the number in ascending order, BUT skipped the number end in zero and zero number..in javax swing"please...

/* REXX is a better programming language than Java with Swing */
data = '11 10 0 3 12'

filtered = ''
do while (data > ' ')
parse var data value data
if left(reverse(value),1) = '0' | (value % 10 = value / 10) then iterate
if value = 0 then do; say 'Excluding:' value; iterate; end
filtered = filtered value
end
say 'After filtering, numbers are:' filtered
keep = filtered

parse var filtered smallest filtered
do while (filtered > ' ')
parse var filtered value filtered
if value < smallest then smallest = value
end
say 'Smallest value is:' smallest

n = words(keep)
do j = 1 to n
sorted.j = word(keep,j)
end

say 'Smallest to largest:'
do j = 1 to n
do k = (j+1) to n
if sorted.j <= sorted.k then iterate
t = sorted.j
sorted.j = sorted.k
sorted.k = j
end
say j sorted.j
end
say 'Done:'
exit

Jan 29, 2009 | Computers & Internet

### Please Solve this C++ Program

Write a program to prompt the user to input several lines of input. A line of inputs is terminated by '*'. For each readline of input the program should output:(use pointer notation for the array) . The total # of words . The lenght of the longest word in the line At the end the program should output: . The total number of words read in all lines of input . The lenght of the longest word read in all lines of input

Jan 19, 2009 | Computers & Internet

### C++ problem

I guess this can be done quite easily with stl sort function:
http://www.sgi.com/tech/stl/sort.html
You can also code a sorting algorithm like quicksort or bubblesort yourself. This is quite fun!

Nov 28, 2008 | Computers & Internet

### Pls. help me

Q.2#  Dim n, sum as Double
Dim i as Integer
n=100
sum=0

for i=1 to n
sum=sum+1/n
next i

Q.3#  Dim sum as Double
sum=0
for i=1 to 99
if i%2 <> 0 then sum=sum+i end if
next i

Sep 16, 2008 | Microsoft AccRepair DS2 2004 for Fr...

### Java programming: file access

(R.id.note) this is the error in java, How can I rectify it;

Aug 29, 2008 | Computers & Internet

### Plz give me C code for the given program

I have the code in java. can you convert.
if need
mail to p.stivel@gmail.com

Feb 23, 2008 | Computers & Internet

## Open Questions:

#### Related Topics:

228 people viewed this question

Level 3 Expert

Level 3 Expert