Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

What types of sensors do businesses use to track activity?

Answered: 1 week ago