Question: I need help finishing this coding homework. I've gotten stuck on the final part, and nothing I'm doing seems to be working. Please help! /*
I need help finishing this coding homework. I've gotten stuck on the final part, and nothing I'm doing seems to be working. Please help!
/* Write a program to store the binary numbers in a file. The file name is entered * by the user. And have to input the number. Your program will store all the binary numbers * starting from 0 to the number entered by the user. After that write another * program to use that file to perform above operations */ import java.util.*; import java.io.*; public class StoreBinary { public static void main(String args[]) throws IOException{ String binary, fileName; Scanner sc = new Scanner (System.in); int i, start; System.out.print(" Enter upper bound value like 4, 8, 16 and so on : "); i = sc.nextInt(); sc.nextLine(); //to clear the keyboard buffer. System.out.print(" Enter file name : "); fileName = sc.nextLine(); FileWriter fw = new FileWriter("./Data/" + fileName + ".txt"); int numOfBits = Integer.toBinaryString(i-1).length(); for(start = 0; start
/* This program reads the file/program mentioned above and displays it in the output below */
import java.util.*; import java.io.*; public class ReadBinary { public static void main(String args[]) throws IOException { String binary, fileName, f, g, h; Scanner scanner = new Scanner(System.in); int i, start; System.out.println("Please enter the file name"); fileName = scanner.nextLine(); Scanner fr = new Scanner(new File ("./Data/" + fileName + ".txt")); System.out.println("a | b | c | d | f | g | h "); while(fr.hasNextLine()) { binary = fr.nextLine(); //final bit of code goes here } } }
Output:

Bluel: Terminal Window - MyProject Options gh a bc df 0|0|0|0|0|1|0 0 0 0 | 1|0|0 1 oi oi 110111011 0|0|1|1|0|0 | 1 0 1 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 1 0 0 | 1|1|0|0|0 | 1 0 | 1|1|1|1|0 | 1 1|0|0|0|1|0|0 1|0|0|1|0|0|0 1|0|1|0|0|1|0 1 | 0 | 1|1|0|0 | 1 1|1|0|0|0|0|0 1|1|0|1|1|0|0 1|1|0|0|0|0 1|1|1|0|1|0 1 Can only enter input while your programming is running Type here to search O CA ENG IN 8:50 AM 2/15/2021 Bluel: Terminal Window - MyProject Options gh a bc df 0|0|0|0|0|1|0 0 0 0 | 1|0|0 1 oi oi 110111011 0|0|1|1|0|0 | 1 0 1 0 0 0 0 0 0 1 1 1 0 1 1 1 0 1 1 0 0 | 1|1|0|0|0 | 1 0 | 1|1|1|1|0 | 1 1|0|0|0|1|0|0 1|0|0|1|0|0|0 1|0|1|0|0|1|0 1 | 0 | 1|1|0|0 | 1 1|1|0|0|0|0|0 1|1|0|1|1|0|0 1|1|0|0|0|0 1|1|1|0|1|0 1 Can only enter input while your programming is running Type here to search O CA ENG IN 8:50 AM 2/15/2021
Step by Step Solution
There are 3 Steps involved in it
To finish the code for storing and reading binary numbers according to your requirements you need to complete the logic in both programs Heres how you ... View full answer
Get step-by-step solutions from verified subject matter experts
