Please run the program and show the result with screenshots after. Thank you (Java Eclipse)
Customer Data: Area Codes
Jiming Wu
F
4082123458
James Brown
M
8315678432
Leanna Perez
F
4087654433
Xing Li
M
8313214555
Stacey Cahill
O
8312123333
Mohammed Abbas
M
4083134444
Kumari Chakrabarti
F
4086667777
Shakil Smith
M
4082123333
Jung Ahrin
F
8319257788
Pedro Martinez
M
4086162323
Ally Gu
O
4089256776
Tamara White
F
8317778978
Alvin Ngo
M
4089256677
Abir Fadel
M
8316645325
Brad Feinman
M
8312023443
Xiaohang Yue
M
8318990033
Method requirements
The method is named capitalizeName
It take in an array of Strings
It capitalizes all of the letters in each String of the array
This method must use a for loop. It cannot call any outside methods that we have not discussed in this class.
It returns nothing.
/*
* @author
* CIS 36A
*/
import java.io.*;
import java.util.Scanner;
public class AreaCodes {
public static void main(String[] args) throws
IOException {
String name, gender, phone;
//Declare your two arrays
here - one per area code
//Declare File and Scanner
//Below variables to keep track of array index in loop
int i = 0;
int j = 0;
while(??????) {
//read in name and gender
//if statements related to gender
//read in phone
//if statements for phone
}
//call capitalizeNames method twice
//call printArray method twice
//close Scanner
}
//write Javadoc comment here
public static void capitalizeNames(String[] names) {
return;
}
//write Javadoc comment here
public static void printArray(String[] names, String fileName){//throw IOException
return;
}
}
MS. JIMING WU
MS. LEANNA PEREZ
MR. MOHAMMED ABBAS
MS. KUMARI CHAKRABARTI
MR. SHAKIL SMITH
MR. PEDRO MARTINEZ
MX. ALLY GU
MR. ALVIN NGO
MR. JAMES BROWN
MR. XING LI
MX. STACEY CAHILL
MS. JUNG AHRIN
MS. TAMARA WHITE
MR. ABIR FADEL
MR. BRAD FEINMAN
MR. XIAOHANG YUE
Following is the complete code for the above problem:
/*
* @author
* CIS 36A
*/
import java.io.*;
import java.util.Scanner;
public class AreaCodes {
public static void main(String[] args) throws IOException {
String name, gender, phone;
//Declare your two arrays here - one per area code
String[] names_408 = new String[8];
String[] names_831 = new String[8];
//Declare File and Scanner
File f = new File("customers.txt");
Scanner scan = new Scanner(f);
//Below variables to keep track of array index in loop
int i = 0;
int j = 0;
while(scan.hasNextLine()) {
//read in name and gender
name = scan.nextLine();
gender = scan.nextLine();
String prefix = null;
//if statements related to gender
if(gender.equals("M") ||
gender.equals("m")) {
name = "mr. " + name;
}else if(gender.equals("F") ||
gender.equals("f")) {
name = "ms. " + name;
}else {
name = "mx. " + name;
}
//read in phone
phone = scan.nextLine();
//if statements for phone
if(phone.startsWith("408")) {
names_408[i++] =
name;
}else {
names_831[j++] =
name;
}
}
//call capitalizeNames method twice
capitalizeNames(names_831);
capitalizeNames(names_408);
//call printArray method twice
printArray(names_408, "SJCustomers.txt");
printArray(names_831, "SCCustomers.txt");
//close Scanner
scan.close();
}
//write Javadoc comment here
public static void capitalizeNames(String[] names)
{
for(int i = 0;i<names.length;i++) {
names[i] =
names[i].toUpperCase();
}
return;
}
//write Javadoc comment here
public static void printArray(String[] names, String
fileName) throws IOException{//throw IOException
FileWriter fw = new FileWriter(new
File(fileName));
for(int i = 0;i<names.length;i++) {
String line = names[i] +
"\n";
fw.write(line);
//System.out.println(line);
}
fw.close();
return;
}
}
After running the following program with the given file, the output file are as follows:
If you have
any problem regarding the understanding of the solution, do let me
know in the comment section.
Don't forget to like the solution, it really means a lot.
Thanks
Please run the program and show the result with screenshots after. Thank you (Java Eclipse) Customer...
Lab 1.4: Arrays, File I/O and Method Review (40 pts) Assume you work for a company that received a list of email addresses of potential new customers from a data broker. Your company receives a file named customers.txt with the below information: Jiming Wu [email protected] James Brown [email protected] Leanna Perez [email protected] Xing Li [email protected] Stacey Cahill [email protected] Mohammed Abbas [email protected] Kumari Chakrabarti [email protected] Shakil Smith Shakattaq2G.com Jung Ahrin [email protected] Pedro Martinez [email protected] Ally Gu [email protected] Tamara White [email protected] Alvin Ngo...
User Profiles Write a program that reads in a series of customer information -- including name, gender, phone, email and password -- from a file and stores the information in an ArrayList of User objects. Once the information has been stored, the program should welcome a user and prompt him or her for an email and password The program should then use a linearSearch method to determine whether the user whose name and password entered match those of any of...
Write a Java program to read customer details from an input text file corresponding to problem under PA07/Q1, Movie Ticketing System The input text file i.e. customers.txt has customer details in the following format: A sample data line is provided below. “John Doe”, 1234, “Movie 1”, 12.99, 1.99, 2.15, 13.99 Customer Name Member ID Movie Name Ticket Cost Total Discount Sales Tax Net Movie Ticket Cost Note: if a customer is non-member, then the corresponding memberID field is empty in...
In Java. Write a GUI contact list application. The program should allow you to input names and phone numbers. You should also be able to input a name and have it display the previously entered phone number. The GUI should look something like the following, although you are welcome to format it in any way that works. This should be a GUI application with a JFrame. The program should contain two arrays of Strings. One array will contain a list...
These are the instructions for a java file. We have not learned array of string or anything that complex. I am trying to solve this possibly using the IndexOf method. 13.4 Assignment 4: Formal Name Generator Complete the generateFormalName method so that... you return the formal name (Mr. or Ms. + last name) given a full name and gender (Strings) as parameters. --You can assume a valid name & gender (any case allowed) is passed in. Example 1: ("Bob Smith",...
Set-Up · Create a new project in your Eclipse workspace named: Lab13 · In the src folder, create a package named: edu.ilstu · Import the following files from T:\it168\Labs\lab13. Note that the .txt file must be in the top level of your project, not inside your src folder. o Student.java o StudentList.java o students.txt Carefully examine the Student.java and StudentList.java files. You are going to complete the StudentList class (updating all necessary Javadoc comments), following the instruction in the code....
I need the following written in Java please, thank you ' We want you to implement a java class that will show details on users and throw exceptions where needed. The following requirements specify what fields you are expected to implement in your User class: - A private String firstName that specifies the first name of the user - A private String lastName that specifies the last name of the user - A private int age that specifies user's age...
#PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a list of up to 10 players and their high scores in the computer's memory. Use two arrays to manage the list. One array should store the players' names, and the other array should store the players' high scores. Use the index of the arrays to correlate the names with the scores. Your program should support the following features: a. Add a new player and...
Need code written for a java eclipse program that will follow the skeleton code. Exams and assignments are weighted You will design a Java grade calculator for this assignment. A user should be able to calculate her/his letter grade in COMS/MIS 207 by inputting their scores obtained on worksheets, assignments and exams into the program. A skeleton code named GradeCompute.java containing the main method and stubs for a few other methods, is provided to you. You must not modify/make changes...
Java Description This project is designed to help you practice for the second midterm examination. First you will hand write the code for the project, just as you would do on the examination. Then you will take your hand written code and enter it into eclipse and debug/fix it. This should help you identify challenges that you have in hand writing code that could cause problems on the midterm on Wednesday Write a program that generates platitudes, by writing each...