top of page

Coding Practice: Hoe Check

  • Writer: Ruby Moley
    Ruby Moley
  • Sep 21, 2024
  • 2 min read

Updated: Dec 3, 2024

Published on 9 / 21 / 2024


If you didn't already know, I am a Computer Science minor! I love coding. To learn new methods and implementations of programming, I create programs with silly variables and concepts. In this one, I made "Hoe" objects (yes, you heard that right). I know it sounds so dumb, but it helps me remember hard methods and classes. Since starting my current computer science class, I realized I need to practice to get back into the coding mindset. With creative practice like this, I improve my coding skills while also having a laugh.


The small code below manages a people file, scans the information, and then processes it. It implements BufferedReader, File Management, Scanners, Exceptions, and Object handling.


Hoe Class

import java.io.*;
import java.util.Scanner;
public class HoeCheck {
		public static void main(String[] args) {
			BufferedReader buffer = null;
			try {
				buffer = new BufferedReader(new FileReader("data.txt"));
				String line = buffer.readLine();
					Scanner scanLine = new Scanner(line);
						String name = scanLine.next();
						int bitches = scanLine.nextInt();
						System.out.println(name + bitches);
					scanLine.close();
					line = buffer.readLine();
			
				buffer.close();
			} catch (IOException e) {
				System.out.println(e.getMessage());
			}
		}
}

File Reader Class

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

public class FileReadWithBoth {
    public static void main(String[] args) {
        try {
            BufferedReader buffer = new BufferedReader(new FileReader("data.txt"));
            String line;
            while ((line = buffer.readLine()) != null) {
                Scanner lineScanner = new Scanner(line);
                while (lineScanner.hasNext()) {
                    String word = lineScanner.next();
                    System.out.print(word.toUpperCase() + " "); // Example processing: convert to uppercase
                }
                System.out.println();
                lineScanner.close();
            }
            buffer.close();
        } catch (IOException e) {
            System.out.println("An error occurred: " + e.getMessage());
        }
    }
}

Let me know if you have any coding recommendations for me! Thank you!

 
 
 

Comments


file (18).png

Let's chat!!!

Thanks for submitting!

© 2035 by Annabelle. Wix

file (19).png
bottom of page