abhas Active member
| Subject: Way to write computer ix x project program ICSE Sat Nov 01, 2008 10:24 pm | |
| Way to write computer ix x project program ICSE
This is a sample program 4 computer java project you can know the way to write progs. by seeing this...
Always remember to write variable description and comments
import java.io.*;
class prog3
{
void main( )throws IOException
{
BufferedReader Aj=new BufferedReader(new InputStreamReader(System.in));
//Aj is object to take input from standard input device
String n[]=new String[30];//Array of Strings with 30 elements
//to store names
int m[]=new int[30];//Array of integer(int) with 30 elements
//to store marks
int a;
for(a=0;a<30;a++)
{//start of for loop
System.out.println("Enter name of the student");
n[a]=Aj.readLine();//taking names as input
System.out.println("Enter his marks");//displaying related message
m[a]=Integer.parseInt(Aj.readLine());//taking marks as input
System.out.println(" ");//for a blank line
}//end of loop
System.out.println("Unsorted data");//displaying related message
System.out.println("Name Marks");//displaying related message
System.out.println(" ");//for a blank line
for(a=0;a<30;a++)
System.out.println(n[a]+" "+m[a]);//displaying unsorted data
System.out.println(" ");//for a blank line
//sorting data bubble sort
int temp;
String Temp;
for (a=0;a<30;a++)
{//start of outer for loop
for (int c=0;c<29-a;c++)
{//start of inner for loop
if(m[c]<m[c+1])
{//start of if condition
/*
* interchanging values of m[c] & m[c+1]
* and n[c] & n[c+1] also for sorting
*/
temp=m[c];
m[c]=m[c+1];
m[c+1]=temp;
Temp=n[c];
n[c]=n[c+1];
n[c+1]=Temp;
}//end of if condition
}//end of inner for loop
}//end of outer for loop
System.out.println("Sorted data");//displaying related message
System.out.println("Name Marks");//displaying related message
for(a=0;a<30;a++)
System.out.println(n[a]+" "+m[a]);//displaying sorted data
}
}
/**
* Variable Description
* int a - used as control variable in loop
* int c - used as control variable in loop
* int temp- to store value of marks temporarily
* String Temp - to store names temporarily for interchanging values
*/ |
|
abhas Active member
| Subject: Re: Way to write computer ix x project program ICSE Sat Nov 01, 2008 10:25 pm | |
| comments have become wrong (have gone 2 next line) bcos i have pasted the prog...
don't do this......... |
|
ashleychan Active member
| Subject: Re: Way to write computer ix x project program ICSE Sat Nov 01, 2008 10:30 pm | |
| is there any siple one using only loop and conditional statements? |
|
abhas Active member
| Subject: Re: Way to write computer ix x project program ICSE Sun Nov 02, 2008 9:33 am | |
| Another sample project prog....
/*To accept the value of units consumed and calculate the bill
* using given rates
* and taking minimum fixed amount tobe paid as Rs.125
*/
class prog1
{
void main(double u)
{
double b=0;
if(u<=200)///when value of unit is less or equal to 200 units
b=2.25*u;//claculating value of bill
else if (u<=350)//when 201-350 units are consumed
b=225+2.75*(u-100);//claculating value of bill
else //when more than 350 units are consumed
b=225+2.75*150+3.25*(u-350);//claculating value of bill
if (b<125)//when bill is less than minimum fixed bill
b=125;//assigning bill's value to minimum fixed amount
b=b+(b*2.5/100);//calculating service tax
System.out.println("Bill :"+b);//printing amount to be paid as bill
}
}
/**
* Variable Description
* double u- to accept the value unit consumed as parameter
* double b- to store the amount to be paid
*/ |
|
Sponsored content
| Subject: Re: Way to write computer ix x project program ICSE | |
| |
|