Joyce Farrell Pg.725, #8 a&b iput file. Save the file as Display an appropriate
ID: 3683164 • Letter: J
Question
Joyce Farrell Pg.725, #8 a&b iput file. Save the file as Display an appropriate message UlnersByName.java. e. Write an application that application that allows you to enter any purchase amount and displays 725 all the data for customers with appropriate message if no custo balances greater than the entered value. Display DisplaySelectedCustomersByBalance-java. Ising a text editor, create a file mers meet the criteria. Save the file as mbers. Read in each account number and display whether it is that contains a list of at least 10 six-digit account numbers. umber is valid only if the last digit is equal to the sum of the first five digts unt number and display whether it is valid. An account um divided by 10. For example, the number 223355 is valid because the sum of the first five digits is 15, the remainder when 15 is divided by 10 is 5, and the last digit is 5. five digits i only valid account numbers to an output file, each on its own line.Save the Write application as ValidateCheckDigits.java. Write an application that allows a user to enter a filename and an integer representing a file position. Assume that the file is in the same folder as your executing program. Access the requested position within the file, and display the next 20 characters there. Save the file as SeekPosition.java. b. Modify the SeekPosition application so that instead of displaying 20 characters, the user enters the number of characters to display, beginning with the requested position. Save the file as SeekPosition2.java. a. Create an application that allows you to enter student data that consists of an ID number, first name, last name, and grade point average. Depending on whether the student's grade point average is at least 2.0, output each record either to a file of students in good standing or those on academic probation. Save the program as 8. StudentsStanding.java Create an application that displays each record in the two files created in the StudentsStanding application in Exercise 8a. Display a heading to introduce the list produced from each file. For each record, display the ID number, first name, last name, grade point average, and the amount by which the grade point average exceeds or falls short of the 2.0 cutoff.Save the program as StudentsStanding2.java. b. an application that creates 10,000 blank records and then allows the user to enter customer account information, including an account number that is 9999 or less a last name, and a balance. Insert each new record into a data file at a location that is equal to the account number. Assume that the user will not enter invalid account numbers. Force each name to eight characters, padding it with spaces a. The Rochester Bank maintains customer records in a random access file. WriteExplanation / Answer
Code: 8(a)
import java.io.*;
import java.util.Scanner;
class StudentsStanding
{
int id;
String fname, lname;
double gradepoint;
StudentsStanding(int id, String fname, String lname, double gradepoint)
{
this.id = id;
this.fname = fname;
this.lname = lname;
this.gradepoint = gradepoint;
}
public void writetoFile() throws IOException
{
if(gradepoint > 2.0)
{
FileWriter f1 = new FileWriter("good_standing.txt", true);
PrintWriter bw1 = new PrintWriter(f1);
String s = id + " " + fname + " " + lname + " " + gradepoint;
bw1.println(s + " ");
bw1.close();
}
if(gradepoint < 2.0)
{
FileWriter f2 = new FileWriter("academic_probation.txt", true);
PrintWriter bw2 = new PrintWriter(f2);
String s1 = id + " " + fname + " " + lname + " " + gradepoint;
bw2.println(s1 + " ");
bw2.close();
}
}
public static void main(String args[]) throws IOException
{
StudentsStanding ss = new StudentsStanding(1, "xxx", "xxx", 1.2);
ss.writetoFile();
StudentsStanding ss1 = new StudentsStanding(2, "yyy", "yyy", 2.3);
ss1.writetoFile();
StudentsStanding ss2 = new StudentsStanding(3, "zzz", "zzz", 4.6);
ss2.writetoFile();
StudentsStanding ss3 = new StudentsStanding(4, "www", "www", 1.8);
ss3.writetoFile();
}
}
Code: 8 (b)
import java.io.*;
class StudentsStanding2
{
public static void main(String args[])
{
String str, str1;
try
{
FileInputStream fis1 = new FileInputStream("good_standing.txt");
BufferedReader br1 = new BufferedReader(new InputStreamReader(fis1));
FileInputStream fis2 = new FileInputStream("academic_probation.txt");
BufferedReader br2 = new BufferedReader(new InputStreamReader(fis2));
System.out.println("Students above grade point 2.0");
while((str = br1.readLine())!=null)
{
System.out.println(str);
}
System.out.println("Students below grade point 2.0");
while((str1 = br2.readLine())!=null)
{
System.out.println(str1);
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.