Pages

සීමාවන් නොමැති අදහස් වලට පණ දෙන්න.....

Monday, October 19, 2009

hiring System program in java ( Command Line Interface )

Equiphire pvt. Ltd supplies 3 major equipments for hire.

Program which created for this company which runs on Command Line Interface. It
could handle using the main menu.

No ---|--- Item ---|--- Daily Rental ---|--- Deposit Value
1 ---|--- Electric Drill - --|--- 800 ---|--- 15000
2 ---|--- Water Pump ---|--- 500 ---|--- 7500
3 ---|--- Electric Jigsaw ---|--- 400 ---|--- 8000


main CLI interface of the program



______________________________________
How it works.
  • This program is a platform independent program. So, it could run on any operating system which has Java installed.
  • It runs on command line interface.
  • It saves data in files and retrieves data from them.
  • Program asks a choice as a numerical input from the keyboard. As mentioned
  • here, we can choose the appropriate value as our need.
_________________________________________________________________________

How could we use the program

• Choice 1 brings the user to the Hiring System.
◦ We can add hire details via the program.
◦ Program will calculate the deposit value needed and the default deposit as well as the return value from the deposit.
◦ Transactions will be saved in a file for future use.

• Choice 2 brings the user to the Daily report.
◦ User could view the daily transactions of the company.
◦ User need to enter appropriate date on the YYYYMMDD format.
◦ System will automatically show every transaction which done in particular day.

• Choice 3 brings the user to the History of the hires of individual customer.
◦ User could easily find the hiring history of a customer using the customer ID.
◦ User need to enter appropriate customer ID in to the system.
◦ System will automatically show every transaction which done by particular customer.

• Choice 4 brings the user to the History of the hires of individual equipment.
◦ User could easily find the hiring history of an equipment using the equipment ID.
◦ User need to enter appropriate Equipment ID in to the system.
◦ System will automatically show a history of the hirings which done on the particular equipment.

• Choice 5 brings the user to the History of the hires of the Company
◦ User could easily find the full hiring history of the Company.

• Choice 6 brings the user to the Customer database.
◦ User could easily find the full list of the Customer database.

• Choice 7 provides the facility to add Customers to the system.
◦ User could easily add Customers to the system.
◦ User need to add the customers name and the email address. Customer ID and registered date will be added automatically to the system.
◦ It will saved in a file for future use.

• Choice 8 provides the facility to add Equipments to the system.
◦ User could easily add a Equipments to the system.
◦ User need to add Equipment ID, Name, daily rental and the Deposit value.
◦ It will saved in a file for future use.


//////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// hiringSystem //
// //
// K.W.Roshan Herath //
// //
// //
// //
// //
// //
//______________________________________________________________________________________________//
// created on opnSUSE 11.0 with //
// java version "1.6.0_06" //
// Java(TM) SE Runtime Environment (build 1.6.0_06-b02) //
// Java HotSpot(TM) Client VM (build 10.0-b22, mixed mode) //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////


import java.util.*;

import java.io.*;

import java.lang.*;
import java.lang.String.*;



class hiringSystem
{

private InputStreamReader ir=new InputStreamReader(System.in);


private BufferedReader br;

private FileOutputStream fos;

private PrintStream ps;

private FileReader frs;


//function to check the existence for a file

private boolean checkFile(String filename)

{

File myFile=new File(filename);

boolean b=myFile.exists();



return b;

}
//////////////////////////////////////////////////////////////////////////////////////////////////
// function to get date //
//////////////////////////////////////////////////////////////////////////////////////////////////

private String fdate()

{
String date;
int month,day,year;
GregorianCalendar calendr;

calendr=new GregorianCalendar();
day=calendr.get(calendr.DATE);
month=calendr.get(calendr.MONTH);
month+=1;//to add january as 1 instead of 0
year=calendr.get(calendr.YEAR);

date = year +""+ month +""+ day;

return date;

}


//////////////////////////////////////////////////////////////////////////////////////////////////
// function to make a hire //
//////////////////////////////////////////////////////////////////////////////////////////////////

private void hire()throws IOException

{
//////////////////////////////////////////////////////////////////
/* String chkcustID,chkcustName,chkemail,chks,chkdateRegd;
long datenow,duration,chkdateReg;

String cline[]=new String[5];


frs=new FileReader("ITE1101As2OctE091041007Customers.txt");

br=new BufferedReader(frs);


while((chks=br.readLine()) != null)

{

cline=chks.split(",");

chkcustID=cline[0];

chkcustName=cline[1];

chkemail=cline[2];

chkdateRegd=cline[3];

}
datenow=(long)fdate();
chkdateReg=(long)chkdateRegd;

duration=datenow-chkdateReg;
*/
//////////////////////////////////////////////////
String custID,datehired,msg,s="y";
String equipID,cuID;
int days,type;
double deposit=0,deposit1=0,rental,returnval;


while(s.equals("y")) {
try{
br=new BufferedReader(ir);

System.out.println("\nEnter Equipment Type");
System.out.println("\n1 FOR ELECTRIC DRILL");
System.out.println("2 FOR WATER PUMP");
System.out.println("3 FOR ELECTRIC JIGSAW ");
System.out.print("\nEnter Equipment Type 1,2,3: ");
type=Integer.parseInt(br.readLine());
System.out.print("\nEnter Equipment ID: ");
equipID=br.readLine();

System.out.print("\nEnter Customer ID: ");
cuID=custID=br.readLine();

System.out.print("\nEnter no of days hired for: ");
days=Integer.parseInt(br.readLine());
datehired=fdate();

System.out.print("\n registered date :"+datehired+"\n\n");

br=new BufferedReader(ir);

if(type==1)
{ deposit=800*days;if(deposit<=15000) deposit1=15000; else deposit1=deposit;} else if(type==2) { deposit=500*days;if(deposit<=15000) deposit1=7500; else deposit1=deposit;} else if(type==3) { deposit=400*days; if(deposit<=15000) deposit1=8000; else deposit1=deposit;} System.out.println("\ndeposit must : "+deposit1); System.out.println("\ndeposit need : "+deposit); returnval=deposit1-deposit; System.out.println("\nretrun value must : "+returnval); fos=new FileOutputStream("ITE1101As2OctE091041007Transaction.txt",true); ps=new PrintStream(fos); ps.println(equipID+","+custID+","+datehired+","+days+","+deposit1+","+deposit+","+returnval); fos.close(); System.out.println("Hire successfull"); } catch(Exception ex) { System.out.println("Error in accepting specifications..."); } } } ////////////////////////////////////////////////////////////////////////////////////////////////// // to view daily report // ////////////////////////////////////////////////////////////////////////////////////////////////// private void dailyReport()throws IOException { String equipID,custID,datehired,days,deposit1,deposit,returnval,s,searchDate; String cline[]=new String[7]; InputStreamReader Ir=new InputStreamReader(System.in); BufferedReader Br=new BufferedReader(Ir); System.out.print("\nEnter date YYYYMMDD: "); searchDate=Br.readLine(); try { frs=new FileReader("ITE1101As2OctE091041007Transaction.txt"); br=new BufferedReader(frs); System.out.println("daily report for : "+searchDate); System.out.println("Equip \tby \thired \t\tforDays \tdeposit\tpayable\treturn"); System.out.println("----------------------------------------------"); while((s=br.readLine()) != null) { cline=s.split(","); equipID=cline[0]; custID=cline[1]; datehired=cline[2]; days=cline[3]; deposit1=cline[4]; deposit=cline[5]; returnval=cline[6]; if(datehired.equals(searchDate)){ System.out.println(datehired+"\t"+equipID+"\t"+custID+"\t"+days+"\t\t"+deposit1+"\t"+deposit+"\t"+returnval); } }} catch(Exception ex) { System.out.println("Some exceptions occured..."); System.out.println("Could not generate the Customer report...!"); } } ////////////////////////////////////////////////////////////////////////////////////////////////// // to view hire history for individual customer // ////////////////////////////////////////////////////////////////////////////////////////////////// private void indCust()throws IOException { String equipID,custID,datehired,days,deposit1,deposit,returnval,s,customerID; String cline[]=new String[7]; InputStreamReader Ir=new InputStreamReader(System.in); BufferedReader Br=new BufferedReader(Ir); System.out.print("\nEnter Customer ID: "); customerID=Br.readLine(); try { frs=new FileReader("ITE1101As2OctE091041007Transaction.txt"); br=new BufferedReader(frs); System.out.println("Hire history for : "+customerID); System.out.println("Equip \tby \thired \t\tforDays \tdeposit\tpayable\treturn"); System.out.println("----------------------------------------------"); while((s=br.readLine()) != null) { cline=s.split(","); equipID=cline[0]; custID=cline[1]; datehired=cline[2]; days=cline[3]; deposit1=cline[4]; deposit=cline[5]; returnval=cline[6]; if(custID.equals(customerID)){ System.out.println(custID+"\t"+equipID+"\t"+datehired+"\t"+days+"\t\t"+deposit1+"\t"+deposit+"\t"+returnval); } }} catch(Exception ex) { System.out.println("Some exceptions occured..."); System.out.println("Could not generate the Customer report...!"); } } ////////////////////////////////////////////////////////////////////////////////////////////////// // to view hire history for equipments // ////////////////////////////////////////////////////////////////////////////////////////////////// private void indEquip()throws IOException { String equipID,custID,datehired,days,deposit1,deposit,returnval,s,equipmentID; String cline[]=new String[7]; InputStreamReader Ir=new InputStreamReader(System.in); BufferedReader Br=new BufferedReader(Ir); System.out.print("\nEnter Equipment ID: "); equipmentID=Br.readLine(); try { frs=new FileReader("ITE1101As2OctE091041007Transaction.txt"); br=new BufferedReader(frs); System.out.println("Hire history for : "+equipmentID); System.out.println("Equip \tby \thired \t\tforDays \tdeposit\tpayable\treturn"); System.out.println("----------------------------------------------"); while((s=br.readLine()) != null) { cline=s.split(","); equipID=cline[0]; custID=cline[1]; datehired=cline[2]; days=cline[3]; deposit1=cline[4]; deposit=cline[5]; returnval=cline[6]; if(equipID.equals(equipmentID)){ System.out.println(equipID+"\t"+custID+"\t"+datehired+"\t"+days+"\t\t"+deposit1+"\t"+deposit+"\t"+returnval); } }} catch(Exception ex) { System.out.println("Some exceptions occured..."); System.out.println("Could not generate the Customer report...!"); } } ////////////////////////////////////////////////////////////////////////////////////////////////// // displayReport() // ////////////////////////////////////////////////////////////////////////////////////////////////// private void displayReport() { String equipID,custID,datehired,days,deposit1,deposit,returnval,s; String cline[]=new String[7]; try { frs=new FileReader("ITE1101As2OctE091041007Transaction.txt"); br=new BufferedReader(frs); System.out.println("Equip \tby \thired \t\tforDays \tdeposit\tpayable\treturn"); System.out.println("----------------------------------------------"); while((s=br.readLine()) != null) { cline=s.split(","); equipID=cline[0]; custID=cline[1]; datehired=cline[2]; days=cline[3]; deposit1=cline[4]; deposit=cline[5]; returnval=cline[6]; System.out.println(equipID+"\t"+custID+"\t"+datehired+"\t"+days+"\t\t"+deposit1+"\t"+deposit+"\t"+returnval); } } catch(Exception ex) { System.out.println("Some exceptions occured..."); System.out.println("Could not generate the daily transaction report...!"); } } ////////////////////////////////////////////////////////////////////////////////////////////////// // to view customer details // ////////////////////////////////////////////////////////////////////////////////////////////////// private void viewCust() { String custID,custName,email,dateRegd,s; String cline[]=new String[4]; try { frs=new FileReader("ITE1101As2OctE091041007Customers.txt"); br=new BufferedReader(frs); System.out.println("Customer ID \tCustomer Name \temail \t\tDate registered "); System.out.println("----------------------------------------------"); while((s=br.readLine()) != null) { cline=s.split(","); custID=cline[0]; custName=cline[1]; email=cline[2]; dateRegd=cline[3]; System.out.println(custID+"\t\t"+custName+"\t\t\t"+email+"\t"+dateRegd); } } catch(Exception ex) { System.out.println("Some exceptions occured..."); System.out.println("Could not generate the Customer report...!"); } } ////////////////////////////////////////////////////////////////////////////////////////////////// // function to add a customer // ////////////////////////////////////////////////////////////////////////////////////////////////// //function for auto-generating the customer id private String generate_id() { String id=" "; String thisLine; String[] fullText = new String[200]; String[] lastLine=new String[5]; int counter=0,nid=0,l=0,z=0; boolean b=checkFile("ITE1101As2OctE091041007Customers.txt"); if(b==false) { id="00001"; } else { try { frs=new FileReader("ITE1101As2OctE091041007Customers.txt"); br=new BufferedReader(frs); while((thisLine=br.readLine()) != null) { counter=counter+1; fullText[counter] = thisLine; } frs.close(); lastLine=fullText[counter].split(","); nid=Integer.parseInt(lastLine[0]); nid=nid+1; l=(String.valueOf(nid)).length(); z=5-l; for(int i=1;i<=z;i++) { id=id+"0"; } id=id+String.valueOf(nid); id=id.substring(1); } catch(Exception ex) { System.out.println("Could not generate the Customer ID...!"); } } return id; } //function to add new Customer private void addCustomer() { String desc; String cust,email,regd; String id; try { id=generate_id(); System.out.print("\n Customer ID :"+id+"\n"); br=new BufferedReader(ir); System.out.print("\n Customer Name : "); cust=br.readLine(); System.out.print("\n Email : "); email=br.readLine(); regd=fdate(); System.out.print("\n registered date :"+regd+"\n\n"); br=new BufferedReader(ir); fos=new FileOutputStream("ITE1101As2OctE091041007Customers.txt",true); ps=new PrintStream(fos); ps.println(id+","+cust+","+email+","+regd); fos.close(); System.out.println("Successfully added one Customer..."); } catch(Exception ex) { System.out.println("Error in accepting Customer specifications..."); } } ////////////////////////////////////////////////////////////////////////////////////////////////// // function to add an Equipment // ////////////////////////////////////////////////////////////////////////////////////////////////// private boolean checkFile1(String filename) { File myFile1=new File(filename); boolean b1=myFile1.exists(); return b1; } boolean b1=checkFile1("ITE1101As2OctE091041007Equipments.txt"); //function to add new equipment private void addEquipment() { String equip; double drent=0; double deposit=0; String id; int availability=1; try { br=new BufferedReader(ir); System.out.print("\n Equipment ID :"); id=br.readLine(); System.out.print("\n Equipment Name : "); equip=br.readLine(); System.out.print("\n Daily rental :"); drent=Double.parseDouble(br.readLine()); System.out.print("\n Deposit :"); deposit=Double.parseDouble(br.readLine()); fos=new FileOutputStream("ITE1101As2OctE091041007Equipments.txt",true); ps=new PrintStream(fos); ps.println(id+","+equip+","+drent+","+availability+","+deposit); fos.close(); System.out.println("Successfully added one Equipment"); } catch(Exception ex) { System.out.println("Error in accepting specifications..."); } } ////////////////////////////////////////////////////////////////////////////////////////////////// // HELP // ////////////////////////////////////////////////////////////////////////////////////////////////// /*private void help() { System.out.println(" HIRING SYSTEM HELP "); }*/ ////////////////////////////////////////////////////////////////////////////////////////////////// // MAIN Method // ////////////////////////////////////////////////////////////////////////////////////////////////// public static void main(String args[]) throws IOException { hiringSystem inv=new hiringSystem(); int ch=0; String s; InputStreamReader ir=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(ir); System.out.println("\n\n\n"); System.out.println("--------------------------------------------------"); System.out.println(" EquipHire Pvt. Ltd "); System.out.println(" උපකරණ කුලියට දීම "); System.out.println("--------------------------------------------------\n"); System.out.println("1. HIRE AN EQUIPMENT"); System.out.println("2. TO VIEW THE DAILY REPORT"); System.out.println("3. TO VIEW HIRE HISTORY OF A CUSTOMER"); System.out.println("4. TO VIEW HIRE HISTORY OF AN EQUIPMENT"); System.out.println("5. VIEW FULL HIRING REPORT"); System.out.println("6. VIEW ALL CUSTOMERS"); System.out.println("7. ADD NEW CUSTOMER"); System.out.println("8. ADD AN EQUIPMENT"); System.out.println("---------------------------------"); System.out.println("9. Exit"); begin: while(ch!=9) { System.out.print("\n"); System.out.print("\n Enter a choice and Press ENTER to continue[1-9]:"); ch=Integer.parseInt(br.readLine()); if(ch>9||ch<1)

{

System.out.println("This doesn't appear to be a valid option...!");

continue begin;

}



////////////////////////////////////////////////////////////////////////////////////////////

if(ch==1)

{

s="y";

while(s.equals("y")||s.equals("Y"))

{

inv.hire();

System.out.print("\n Hire another[y/n]:");

s=br.readLine();

}

}

////////////////////////////////////////////////////////////////////////////////////////////
else

if(ch==2)

{

s="y";

while(s.equals("y")||s.equals("Y"))

{

inv.dailyReport();
System.out.print("\n View again ?[y/n]:");

s=br.readLine();




}

}
////////////////////////////////////////////////////////////////////////////////////////////
else

if(ch==3)

{

s="y";

while(s.equals("y")||s.equals("Y"))

{

inv.indCust();
System.out.print("\n View again ?[y/n]:");

s=br.readLine();


}

}
///////////////////////////////////////////////////////////////////////////////////////////
else

if(ch==4)

{

s="y";

while(s.equals("y")||s.equals("Y"))

{

inv.indEquip();
System.out.print("\n View again ?[y/n]:");

s=br.readLine();



}

}
////////////////////////////////////////////////////////////////////////////////////
else

if(ch==5)

{

inv.displayReport();

}
/////////////////////////////////////////////////////////////////////////////////////
else

if(ch==6)

{

s="y";

while(s.equals("y")||s.equals("Y"))

{

inv.viewCust();
System.out.print("\n View again ?[y/n]:");

s=br.readLine();



}

}
////////////////////////////////////////////////////////////////////////////////////////
else
if(ch==7)

{

s="y";

while(s.equals("y")||s.equals("Y"))

{

inv.addCustomer();

System.out.print("\n Add another[y/n]:");

s=br.readLine();

}

continue begin;

}
////////////////////////////////////////////////////////////////////////////////////////

else
if(ch==8)

{

s="y";

while(s.equals("y")||s.equals("Y"))

{

inv.addEquipment();

System.out.print("\n Add another[y/n]:");

s=br.readLine();

}

}
////////////////////////////////////////////////////////////////////////////////////////


}

System.out.println("Thanks for using this program...!");

}

}


__________________________________________________________________________________

  1. there are some errors in my program.
  2. it needs 3 text files to store data.
  3. before add a customer, it should have atlest 00000 as the1st data in the customer file.
  4. can hire w/o registering as a customer.
  5. can hire equipment which isn't in the equipment file.
  6. cant find the equipment is available to hire or not.
  7. .cant calculate delays.
i'l try to solve these problems as i get free time from my studies. please help me if you can.

Friday, October 9, 2009

how to read unicode fonts in opera mini.

most people use their mobile phone to access the internet. most of them prefer opera mini instead of inbuilt browser which comes with phone.
but when we read any page which written in unicode fonts, we'll see black squares instead of unicode fonts other than normal fonts.
operaMINI solved the problem now.
simply type about:config in address bar and select 'yes' in 'use bitmap fonts for complex scripts' and save it.
you've done

Tuesday, October 6, 2009

a program that would read a number and the base of the number system and print the equivalent decimal value ( for many bases) using Integer.pasrseInt

a program that would read a number and the base of the number system
and print the equivalent decimal value ( for many bases ) using Integer.pasrseInt

01# import java.util.Scanner;
02#
03# public class javaprog{
04#
05# public static void main(String[] args){
06#
07# System.out.println("\n\n\tProgram using Integer.parseInt \n");
08# System.out.println("\t tested with many digits and bases like base 2 to base 10 and base 16 \n");
09#
10# //ask the value to convert
11# System.out.print("Enter the value which you want to convert in to decimal:");
12# Scanner parseint = new Scanner(System.in);
13# String parseintVal=parseint.next();
14#
15# //ask for the base of the value which enterd
16# System.out.print("\nEnter the base of the value which you entered first:");
17# Scanner parseintScan = new Scanner(System.in);
18# int parseintBase = parseintScan.nextInt();
19#
20# //calculation using Integer.parseInt
21# int i= Integer.parseInt(parseintVal,parseintBase);
22#
23# //prints the decimal value
24# System.out.println("\n\t Decimal Value of " +parseintVal+ " ( base "+ parseintBase+ " ) is "+i+"\n");
25#
26# }
27# }
28#


output:
Program using Integer.parseInt
tested with many digits and bases like base 2 to base 10 and base 16
Enter the value which you want to convert in to decimal:123ACD
Enter the base of the value which you entered first:16
Decimal Value of 123ACD ( base 16 ) is 1194701

a program that would read a number and the base of the number system and print the equivalent decimal value ( for many bases) using Integer.pasrseInt

a program that would read a number and the base of the number system
and print the equivalent decimal value ( for many bases ) using Integer.pasrseInt

01# import java.util.Scanner;
02#
03# public class javaprog{
04#
05# public static void main(String[] args){
06#
07# System.out.println("\n\n\tProgram using Integer.parseInt \n");
08# System.out.println("\t tested with many digits and bases like base 2 to base 10 and base 16 \n");
09#
10# //ask the value to convert
11# System.out.print("Enter the value which you want to convert in to decimal:");
12# Scanner parseint = new Scanner(System.in);
13# String parseintVal=parseint.next();
14#
15# //ask for the base of the value which enterd
16# System.out.print("\nEnter the base of the value which you entered first:");
17# Scanner parseintScan = new Scanner(System.in);
18# int parseintBase = parseintScan.nextInt();
19#
20# //calculation using Integer.parseInt
21# int i= Integer.parseInt(parseintVal,parseintBase);
22#
23# //prints the decimal value
24# System.out.println("\n\t Decimal Value of " +parseintVal+ " ( base "+ parseintBase+ " ) is "+i+"\n");
25#
26# }
27# }
28#


output:
Program using Integer.parseInt
tested with many digits and bases like base 2 to base 10 and base 16
Enter the value which you want to convert in to decimal:123ACD
Enter the base of the value which you entered first:16
Decimal Value of 123ACD ( base 16 ) is 1194701

a program that would read a number and the base of the number system and print the equivalent decimal value

a program that would read a number and the base of the number system
and print the equivalent decimal value ( for bases less than 10 ) using Math.pow

01# import java.util.Scanner;
02#
03# public class javaprog{
04#
05# public static void main(String[] args){
06#
07# //base of the value which enterd
08# System.out.print("Enter the base of the value which you wish to enter :");
09# Scanner scan = new Scanner(System.in);
10# double base = scan.nextInt();
11#
12# //value to convert
13# System.out.println("\n You need to add zero '0' in front of the value, if itdoesn't have 8 digits \n");
14# System.out.print("Enter the value which you want to convert in to decimal:");
15# Scanner value = new Scanner(System.in).useDelimiter("");
16#
17# //scans the value by nextInt(); and saves them as int
18# int d0=value.nextInt();
19# int d1=value.nextInt();
20# int d2=value.nextInt();
21# int d3=value.nextInt();
22# int d4=value.nextInt();
23# int d5=value.nextInt();
24# int d6=value.nextInt();
25# int d7=value.nextInt();
26#
27# //calculates the powers using Math.pow(base,exp);
28# int v7=(int)Math.pow(base,7)*d0;
29# int v6=(int)Math.pow(base,6)*d1;
30# int v5=(int)Math.pow(base,5)*d2;
31# int v4=(int)Math.pow(base,4)*d3;
32# int v3=(int)Math.pow(base,3)*d4;
33# int v2=(int)Math.pow(base,2)*d5;
34# int v1=(int)Math.pow(base,1)*d6;
35# int v0=(int)Math.pow(base,0)*d7;
36#
37# //calculates the sum of v0 to v7
38# int decimalValue=v0+v1+v2+v3+v4+v5+v6+v7;
39#
40# //casting base to int
41# int base1=(int)base;
42#
43# //prints the result
44# System.out.println("\n\tYou entered : " +d0+d1+d2+d3+d4+d5+d6+d7 + " with base : " +base1 );
45# System.out.println("\n\tdeciaml value for : " +d0+d1+d2+d3+d4+d5+d6+d7 +" using Math.pow is :"+ decimalValue);
46#
47# }
48# }




output:

Enter the base of the value which you wish to enter :8
You need to add zero '0' in front of the value, if it doesn't have 8 digits
Enter the value which you want to convert in to decimal:45454545
You entered : 45454545 with base : 8
deciaml value for : 45454545 using Math.pow is :9853285

a program that would read a number and the base of the number system and print the equivalent decimal value

a program that would read a number and the base of the number system
and print the equivalent decimal value ( for bases less than 10 ) using Math.pow

01# import java.util.Scanner;
02#
03# public class javaprog{
04#
05# public static void main(String[] args){
06#
07# //base of the value which enterd
08# System.out.print("Enter the base of the value which you wish to enter :");
09# Scanner scan = new Scanner(System.in);
10# double base = scan.nextInt();
11#
12# //value to convert
13# System.out.println("\n You need to add zero '0' in front of the value, if itdoesn't have 8 digits \n");
14# System.out.print("Enter the value which you want to convert in to decimal:");
15# Scanner value = new Scanner(System.in).useDelimiter("");
16#
17# //scans the value by nextInt(); and saves them as int
18# int d0=value.nextInt();
19# int d1=value.nextInt();
20# int d2=value.nextInt();
21# int d3=value.nextInt();
22# int d4=value.nextInt();
23# int d5=value.nextInt();
24# int d6=value.nextInt();
25# int d7=value.nextInt();
26#
27# //calculates the powers using Math.pow(base,exp);
28# int v7=(int)Math.pow(base,7)*d0;
29# int v6=(int)Math.pow(base,6)*d1;
30# int v5=(int)Math.pow(base,5)*d2;
31# int v4=(int)Math.pow(base,4)*d3;
32# int v3=(int)Math.pow(base,3)*d4;
33# int v2=(int)Math.pow(base,2)*d5;
34# int v1=(int)Math.pow(base,1)*d6;
35# int v0=(int)Math.pow(base,0)*d7;
36#
37# //calculates the sum of v0 to v7
38# int decimalValue=v0+v1+v2+v3+v4+v5+v6+v7;
39#
40# //casting base to int
41# int base1=(int)base;
42#
43# //prints the result
44# System.out.println("\n\tYou entered : " +d0+d1+d2+d3+d4+d5+d6+d7 + " with base : " +base1 );
45# System.out.println("\n\tdeciaml value for : " +d0+d1+d2+d3+d4+d5+d6+d7 +" using Math.pow is :"+ decimalValue);
46#
47# }
48# }




output:

Enter the base of the value which you wish to enter :8
You need to add zero '0' in front of the value, if it doesn't have 8 digits
Enter the value which you want to convert in to decimal:45454545
You entered : 45454545 with base : 8
deciaml value for : 45454545 using Math.pow is :9853285

Friday, September 11, 2009

Broadband technologies



Broadband Internet access, which widely called broadband is more faster and reliable than Dial-Up internet access.

There isn't a registered or accurate explenation for Broadband, the speed ranging up from 64 kbit/s up to 8 Mbit/s and more. the 2006 OECD report is typical by defining broadband as having download data transfer rates equal to or faster than 256 kbit/s, while the United States (US) Federal Communications Commission (FCC) as of 2009, defines "Basic Broadband" as data transmission speeds exceeding 768 kilobits per second (Kbps).

Data rates are defined in terms of maximum download because several common consumer broadband technologies such as ADSL are "asymmetric"—supporting much slower maximum upload data rate than download.

"Broadband penetration" is now treated as a key economic indicator.

Although ISPs advertised about their bandwidth, customer/user can't get the actual bandwidth which ISP tells because of the overselling the bandwidth and the quality of the equipments.



Broadband technologies :


  • Mainly consists of DSL and Cable modems.

  • In some areas where DSL or Cable modems didn't available, there are wireless internet connecting options like Wi-Fi, HSDPA, EV-D0 and WiMax.


DSL ( Digital subscriber line )

Digital subscriber line, or DSL, is more expensive than dialup, but provides a faster

connection. DSL also uses telephone lines, but unlike dialup access, DSL provides a

continuous connection to the Internet. This connection option uses a special high-speed

modem that separates the DSL signal from the telephone signal and provides an Ethernet

connection to a host computer or LAN.


Digital Subscriber Line (DSL) technology is a modem technology that uses existing twisted-pair telephone lines to transport high-bandwidth data.

xDSL technologies

  • ADSL

  • SDSL

  • HDSL

  • HDSL-2

  • G.SHDL

  • IDSL

  • VDSL



xDSL is drawing significant attention from implementers and service providers because it promises to deliver high-bandwidth data rates to dispersed locations with relatively small changes to the existing telco infrastructure.

xDSL services are

  • dedicated

  • point-to-point



public network access over twisted-pair copper wire on the local loop (last mile) between a network service provider's (NSP) central office and the customer site, or on local loops created either intrabuilding or intracampus.




ADSL-Asymmetric Digital Subscriber Line

Allows more bandwidth downstream—from an NSP's central office to the customer site—than upstream from the subscriber to the central office. This asymmetry, combined with always-on access (which eliminates call setup)



Advantages:

  • Could use phone line and ADSL line at the same time

  • Could use to view videos, listen to songs, download files and for many purpose.

  • More than 6Mbps bandwidth available.

  • Continuous connection / Stable

  • can be purchased with various speed ranges and capabilities

  • Bandwidth is unlimited in some countries

  • can use existing phone line



Disadvantages:

  • Limited to 4Km radius from the nearest telephone exchange.

  • Have to buy a ADSL modem or router.

  • Expensive in some countries.

  • Not available in some areas

  • receiving data is faster than sending data



An ADSL circuit connects an ADSL modem on each end of a twisted-pair telephone line, creating three information channels:

  • a high-speed downstream channel

  • a medium-speed duplex channel

  • a basic telephone service channel



ADSL modems accommodate Asynchronous Transfer Mode (ATM) transport with variable rates and compensation for ATM overhead, as well as IP protocols.



ADSL uses two pieces of equipment, one on the customer end and one at the Internet service provider, telephone company or other provider of DSL services. At the customer's location there is a DSL transceiver, which may also provide other services. The DSL service provider has a DSL Access Multiplexer (DSLAM) to receive customer connections.




The DSLAM at the access provider is the equipment that really allows DSL to happen.



SDSL

  • Symmetric Digital Subscriber Line (SDSL) allows equal bandwidth downstream from an NSP's central office to the customer site as upstream from the subscriber to the central office.

  • SDSL supports data only on a single line and does not support analog calls.

  • The symmetry that SDSL offers, combined with always-on access (which eliminates call setup)

  • Because traffic is symmetrical, file transfer, web hosting, and distance-learning applications can effectively be implemented with SDSL.

HDSL

  • Originally developed by Bellcore, high bit-rate DSL (HDSL)/T1/E1 technologies have been standardized by ANSI (two-pair T1 transmission, with a data rate of 784 kbps on each twisted pair ) in the United States and by ETSI ( two-pair E1 system, with each pair carrying 1168 kbps, and a three-pair E1 system, with 784 kbps on each twisted pair ) in Europe.

  • T1 service can be installed by installing HDSL modems at each end of the line.

  • HDSL is heavily used in cellular telephone buildouts.

  • HDSL does have drawbacks. First, no provision exists for analog voice because it uses the voice band. Second, ADSL achieves better speeds than HDSL because ADSL's asymmetry deliberately keeps the crosstalk at one end of the line. Symmetric systems such as HDSL have crosstalk at both ends.

HDSL-2

  • HDSL-2 is an emerging standard and a promising alternative to HDSL. The intention is to offer a symmetric service at T1 speeds using a single-wire pair rather than two pairs.

  • The biggest advantage of HDSL-2, which was developed to serve as a standard by which different vendors' equipment could interoperate, is that it is designed not to interfere with other services. However, HDSL-2 is full rate only, offering services only at 1.5 Mbps.

ISDN Digital Subscriber Line

  • is a cross between ISDN and xDSL

  • Unlike ISDN, ISDL does not connect through the voice switch. A new piece of data communications equipment terminates the ISDL connection and shuts it off to a router or data switch.

  • This is a key feature because the overloading of central office voice switches by data users is a growing problem for telcos.

  • The limitation of ISDL is that the customer no longer has access to ISDN signaling or voice services. But for Internet service providers, who do not provide a public voice service, ISDL is an interesting way of using POTS dial service to offer higher-speed Internet access, targeting the embedded base of more than five million ISDN users as an initial market.

VDSL

transmits high-speed data over short reaches of twisted-pair copper telephone lines, with a range of speeds depending on actual line length.

The maximum downstream rate under consideration

  • 51 and 55 Mbps over lines up to 1000 feet (300 m) in length.

  • 13 Mbps over lengths beyond 4000 feet (1500 m) are also common.





ISDN ( Integrated Service Digital Network )

Integrated Service Digital Network (ISDN) is one of the oldest broadband digital access method which is a telephone data service standard.


A basic rate ISDN line is an ISDN line with 2 data "bearer" channels (DS0 - 64 kbit/s each). Using the ISDN bonding technology, we can get 256 kbps or more bandwidth.


Advantages :

  • Constant data rate at 64 kbit/s for each DS0 channel.

  • Two way broadband symmetric data transmission, unlike ADSL.

  • One of the data channels can be used for phone conversation without disturbing the data transmission through the other data channel.

  • Call setup is very quick.

  • Low latency

  • ISDN Voice clarity is unmatched by other phone services.

  • Caller ID is available.

  • Maximum distance from the central office is much greater than it is for DSL.

  • When using ISDN-BRI, there is the possibility of using the low-bandwidth 16 kbit/s "D" channel for packet data and for always on capabilities.


Disadvantages


  • ISDN offerings are dwindling in the marketplace due to the widespread use of faster and cheaper alternatives.

  • ISDN routers, terminal adapters ("modems"), and telephones are more expensive than ordinary POTS equipment, like dial-up modems.

  • ISDN provisioning can be complicated due to the great number of options available.

  • ISDN users must dial in to a provider that offers ISDN Internet service, which means that the call could be disconnected.

  • ISDN is billed as a phone line, to which is added the bill for Internet ISDN access.

  • "Always on" data connections are not available in all locations.

  • Some telephone companies charge unusual fees for ISDN, including call setup fees, per minute fees, and higher rates than normal for other services.







Satellite Internet


Is the most expensive way to use the Internet. But availability and bandwidth is greater than other technologies because Satellites can cover any place on the earth by using 3 separate satellites.


Advantages:

  • True global broadband Internet access availability

  • Mobile connection to the Internet

  • High bandwidth


Disadvantages:


  • High latency compared to other broadband services, especially 2-way satellite service

  • Unreliable: drop-outs are common during travel, inclement weather, and during sunspot activity .

  • The narrow-beam highly directional antenna must be accurately pointed to the satellite orbiting overhead

  • One-way satellite service requires a data uplink connection .

  • Satellite dishes are very large.




Cellular broadband / Wireless Internet


  • Cellular phone towers are very widespread, and as cellular networks move to third generation (3G) networks they can support fast data; using technologies such as EVDO, HSDPA and UMTS. These can give broadband access to the Internet, with a cell phone, with Cardbus, ExpressCard, or USB cellular modems, or with cellular broadband routers, which allow more than one computer to be connected to the Internet using one cellular connection.


  • Wi-fi and WiMax technology which provides mobility and connectivity as well as the more bandwidth than Dial-Up.







3G technology

  • A technology which used for mobile telephony, data, video, voice

  • speed differs from 384 kbps to 14.4 Mbps for downlink and till 5.8 Mbps for uplink.


HSDPA ( High-Speed Downlink Packet Access )

  • is a 3G technology

  • Downlink available from 1.8 Mbps , 3.6 Mbps, 7.2 Mbps and 14.4 Mbps.

  • Uplink till 5.8 Mbps


WiMax ( Worldwide Interoperability for Microwave Access )

  • a telecommunications technology that provides wireless transmission of data using a variety of transmission modes, from point- to-multipoint links to portable and fully mobile internet access

  • Provides speed up to 72 Mbps.

  • Based on IEEE 802.16 standard.

uses:

  • Connecting Wi-Fi hotspots to the Internet.

  • Providing a wireless alternative to cable and DSL for "last mile" broadband access.

  • Providing data and telecommunications services.

  • Providing a source of Internet connectivity as part of a business continuity plan.

  • Providing portable connectivity.


Wi-Fi

  • transmit at frequencies of 2.4 GHz or 5 GHz.The higher frequency allows the signal to carry more data.

  • use 802.11 networking standards, which come in several flavors (802.11a, 802.11b , 802.11g, 802.11n

  • allows local area networks (LANs) to be deployed without wires for client devices

  • High mobility

  • Security problems occurs


Advantages of wireless technologies:

  • more bandwidth than Dial-Up.

  • Mobility.

  • Availability.

  • Could use for media steaming, VoIP and many.

  • Easy to connect

  • Speed.



Disadvantages of wireless technologies:

  • Due to the 3G technology is a shared bandwidth service , bandwidth available from one tower could be shared among many users. So, it'll be slower than usual at sometimes.

  • Some service provider's shares single IP address among many users. So, it could make some problems with identity.

  • Service fees could be high.

  • Limited data bundle will be available to use. ( most service provider's don't provide unlimited data bundles )

  • Sometimes , it will have some issues with 3G connectivity although there is a tower nearby.

  • Security problems occurs because it hasn't security features by default.

  • Due to the radio signals, health problems could occur.



Now it's time to compare Dial-Up internet access with Broadband Internet access.


Differences between Dial-Up internet access and Broadband Internet access.

  • In Dialup we can use normal PSTN phone line to access to the Internet if there is a modem available. But we can't use normal PSTN phone line with a Modem or Router without configuring the telephone line for ADSL broadband.

  • Dial-Up internet technology is a lower speed with lower bandwidth and Broadband is not like that.

  • Dial-Up is suitable for light usage and broadband is suitable for heavy usage.

  • Dialup is a low cost method to access the Internet than broadband.

  • Dialup charges for Internet usage and for the time we used to surf the web because it make a call to connect to the Intenet and in Broadband it charges flat rate for a data bundle or for the time.

  • We can't make calls using the phone while browsing, but we can answer to the calls while browsing with broadband technologies.

  • Dialup can't use for VoIP and media streaming but broadband can.

  • When we use Dial-Up , there is a possibility to drop the connection more than Broadband.

  • Dial-Up can't used for mobile workers if there isn't a PSTN line. But some broadband technologies provide mobility.


Posted by K. W. Roshan Herath [ roshan herath ]



Source:

Broadband technologies

    accessed on 08th September, 2009


Digital Subscriber Line

accessed on 08th September, 2009


accessed on 08th September, 2009



Wireless technology


Related Posts with Thumbnails