Pemrograman Berbasis Objek Program Dadu pada JAVA beserta penjelasan
yeah
JAVA PROGRAM TO FIND THE TRANSPOSE OF A MATRIX (A transpose of an array obtained by interchanging the elements of the rows and columns) . WITH COMMENTS AND DETAILS TO HELP YOU UNDERSTAND THE…Full description
grafos y sus aplicaciones.Descripción completa
javaDescription complète
javaDescripción completa
Descripción: This program will teach you how to program with Java
Program Koperasi Simpan PinjamFull description
Contoh pemrograman fuzzy logic untuk pengambilan keputusan menggunakan bahasa pemrograman JavaDeskripsi lengkap
Full description
java
Descripción: Java skills Explained simple . JAVA PROGRAMMING FOR BEGINNERS.
java
quinteto de metales
Descripción completa
Descripción: Java
Descripción: como programar en java, 1er y 2do año de Analisis de sistemas. No se quien sea el autor, pues no lo dice en ninguna parte.
Full description
Description complète
import java.io.File; import java.io.FileWriter; import java.io.PrintWriter; import java.util.Scanner; class Contacts { //Properties public String firstName; public String lastName; public String phone;
} public class FinalPhoneBook { public static void main (String [] args) throws Exception{ Contacts [] entries; entries = new Contacts[100]; Contacts [] entriesErase; entriesErase = new Contacts[100]; int selection = 0; int counter; int indexRemove; String fName,lName,pNumber; String lastName; String firstName; String phoneNumber; String lastErase; String firstErase; String phoneErase; File PhoneBook; PhoneBook = new File("PhoneBook1.txt") File("PhoneBook1.txt"); ; PrintWriter output;
Scanner inSelection = new Scanner(System.in); Scanner input = new Scanner(System.in); do { do{ System.out.println("PHONEBOOK:"); System.out.println("1. Add Contact"); System.out.println("2. View Contacts"); System.out.println("3. Find Contact"); System.out.println("4. Erase Contact"); System.out.println("5. Exit"); System.out.print("Enter selection (1-5): "); if (!inSelection.hasNextInt()) { System.out.println("NOT AN OPTION. PLEASE ENTER AN OPTION (1-5)" );
inSelection.nextLine(); } else { selection = inSelection.nextInt(); if (selection>5 || selection<1){ System.out.println("NOT AN OPTION. PLEASE ENTER AN OPTIO
N (1-5)"); } } }while (selection<1 && selection >5); switch(selection) { case 1: System.out.println("ADD CONTACT:"); System.out.print("First Name:"); fName = inSelection.next(); System.out.print("Last Name:"); lName = inSelection.next(); System.out.print("Phone Number:"); pNumber = inSelection.next(); int i=0; entries[i] = new Contacts(fName,lName,pNumber); System.out.println(entries[i].getContact()+ " was added to PhoneBook");
output = new PrintWriter(new FileWriter(PhoneBook, true)); output.println(entries[i].getContact()); output.close(); i++; break; case 2: System.out.println("CONTACT LIST:"); // Read data from a file Scanner read = new Scanner(PhoneBook); counter = 0; while (read.hasNext()) { lastName = read.next(); firstName = read.next(); phoneNumber = read.next(); Contacts Entry = new Contacts(firstName,lastName,phoneNu
read.close(); System.out.println(counter + " " + "Contacts found."); break; case 3: int d=0; System.out.println("FIND CONTACT: "); System.out.print("Enter First Name or Last Name or Phone Num
ber: "); String namefind = input.next(); Scanner read4= new Scanner(PhoneBook); //Read Phonebook and find matching names and show it in the console. while (read4.hasNext()){ lastName = read4.next(); firstName = read4.next(); phoneNumber = read4.next(); if (namefind.equals(lastName)||namefind.equals(firstName )||namefind.equals(phoneNumber)){ entries[d] = new Contacts(firstName,lastName,phoneNu mber); System.out.println(entries[d].getContact()); d++; } } System.out.println(d + " MATCHS"); break; case 4: int nonErase=0; int erase=0; int e=0; int index=0; int indexFound=0; int indexToErase=0; System.out.println("REMOVE CONTACT: "); System.out.print("Enter First Name or Last Name or Phone Num ber: "); String nameToErase = input.next(); Scanner readToErase= new Scanner(PhoneBook); //Read Phonebook and find matching names and show it in the console. indexRemove=1; while (readToErase.hasNext()){ lastName = readToErase.next(); firstName = readToErase.next(); phoneNumber = readToErase.next(); if (nameToErase.equals(lastName)||nameToErase.equals(fir stName)||nameToErase.equals(phoneNumber)){ entries[e] = new Contacts(firstName,lastName,phoneNu mber); System.out.println(indexRemove + "." +" "+ entries[e ].getContact()); e++; indexFound++; indexRemove++; } } if (indexFound>0){ System.out.print("FOUND MATCH(S). ENTER # TO BE REMOVE: "); index = input.nextInt(); indexToErase = index-1;
// concatenating to get a String String contactErase = entries[indexToErase] + ""; String delimeter= " "; String[] splitContactErase = contactErase.split(delimeter); lastErase = splitContactErase[0]; firstErase = splitContactErase[1]; phoneErase = splitContactErase[2]; Scanner read1 = new Scanner(PhoneBook); //Read Phonebook and delete match while (read1.hasNext()){ lastName = read1.next(); firstName = read1.next(); phoneNumber = read1.next(); if (((firstErase.equals(firstName)) && (lastErase.equals (lastName))) && (phoneErase.equals(phoneNumber))){ entriesErase[erase] = new Contacts(firstName,lastNam e,phoneNumber); System.out.println(entriesErase[erase].getContact()) ; erase++; }else{ entries[nonErase] = new Contacts(firstName,lastName, phoneNumber); nonErase++; } } read1.close(); //Prints matching names to a blank PhoneBook using variables store in entries. output = new PrintWriter(PhoneBook); for (int b=0; b