an expert provide the rest of the coding i need to be able to display the required output question Ask the user for an account balance. Show, in descending order, all the accounts that have a balance greater than what the user input. Each entry is int, string, long, double, boolean (name length, name, credit card number, balance, cashback). req. output Enter a balance\n 9000ENTER Accounts with a balance of at least $9000.00 (sorted by balance)\n Name Account Number Balance Cash Back\n Brand Hallam 3573877643495486 9985.21 No\n Paco Verty 4508271490627227 9890.51 No\n Stanislaw Dhenin 4405942746261912 9869.27 No\n Eachelle Balderstone 30526110612015 9866.30 No\n Reube Worsnop 3551244602153760 9409.97 Yes\n Tiphanie Oland 5100172198301454 9315.15 No\n Jordan Rylstone 201715141501700 9135.90 Yes\n 7 results\n ----- Enter a balance\n 8000ENTER
I need help with finishing my java code
Can an expert provide the rest of the coding i need to be able to display the required output
question
req. output
9000ENTER
Accounts with a balance of at least $9000.00 (sorted by balance)\n
Name Account Number Balance Cash Back\n
Brand Hallam 3573877643495486 9985.21 No\n
Paco Verty 4508271490627227 9890.51 No\n
Stanislaw Dhenin 4405942746261912 9869.27 No\n
Eachelle Balderstone 30526110612015 9866.30 No\n
Reube Worsnop 3551244602153760 9409.97 Yes\n
Tiphanie Oland 5100172198301454 9315.15 No\n
Jordan Rylstone 201715141501700 9135.90 Yes\n
7 results\n
-----
Enter a balance\n
8000ENTER
Accounts with a balance of at least $8000.00 (sorted by balance)\n
Name Account Number Balance Cash Back\n
Brand Hallam 3573877643495486 9985.21 No\n
Paco Verty 4508271490627227 9890.51 No\n
Stanislaw Dhenin 4405942746261912 9869.27 No\n
Eachelle Balderstone 30526110612015 9866.30 No\n
Reube Worsnop 3551244602153760 9409.97 Yes\n
Tiphanie Oland 5100172198301454 9315.15 No\n
Jordan Rylstone 201715141501700 9135.90 Yes\n
Anjela Himsworth 3573904891259172 8985.27 Yes\n
Howie Royson 3581572129932389 8965.07 Yes\n
Blinni Mattke 3549214734886202 8960.76 No\n
Dorotea Nolli 6396392530990977 8790.59 Yes\n
Carita Savill 6767642427889745 8738.77 No\n
Mateo Mollene 5100174906912671 8659.35 Yes\n
Cathleen Schurcke 4041598930132416 8596.39 Yes\n
Adriana Bru 3574931681854879 8482.46 Yes\n
Orlando Nutbeem 6372756913380048 8346.07 No\n
Leland Vasilyev 6394213548410265 8249.76 No\n
Ambrosi Fussie 3581429661693202 8207.40 Yes\n
Valentine Montford 3533184590527943 8176.80 Yes\n
Sarette Springell 5100146117467372 8161.69 Yes\n
Rich Yakovl 490337929898976334 8099.58 Yes\n
Conney Sizeland 3588215263928408 8036.12 Yes\n
22 results\n
my code so far produces the general format of the required output
import java.io.*;
import java.util.ArrayList;
import java.util.Scanner;
public class AccountBalance {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a balance");
double input = keyboard.nextDouble();
System.out.printf("Accounts with a balance of at least $%.2f (sorted by balance)%n", input);
System.out.printf("%20s%20s%10s%12s%n", "Name", "Card Number", "Balance", "Cash Back?");
i need the rest of the code in order to display my required output produced from a binary file called "accounts-with-names.dat"
i am specifically needing the java code in order to call thhis info from the file that WILL WORK
i have tried everything and my code doesnt pull the information from the file
this previous file worked to pull names of length from the binary file "names.dat"
public class Names {
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
System.out.println("Enter a length");
int length = kb.nextInt();
System.out.println("Names of length " + length);
ArrayList<String> names = new ArrayList<>();
try {
DataInputStream input = new DataInputStream(new FileInputStream("names.dat"));
boolean go = true;
while (go)
{
int currentLength=0;
try
{
StringBuffer bf = new StringBuffer();
currentLength = (int) input.readChar();
for(int i=0;i<currentLength;i++) {
char ch = (char) input.readChar();
if(currentLength==length) {
bf.append(ch);
}
}
if(currentLength==length) {
System.out.println(bf.toString());
names.add(bf.toString());
}
} catch(EOFException e)
{
go = false;
}
}
input.close();
}
catch (IOException e)
{
e.printStackTrace();
}
finally {
System.out.println(names.size() + " results");
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images