SpeedType in Java — Day 1 Begins! #30Days30Projects

Rushikesh UngeRushikesh Unge
4 min read

👋 Hey Devs!

Welcome to Day 1 of my #30Days30Projects Challenge in Java 🎯 — where I’m building 30 real projects in 30 days to level up my Java skills, improve problem-solving, and most importantly... stop procrastinating 😅

And what better way to kick things off than with a challenge most of us can relate to — typing fast but not necessarily typing right.

Today’s project is:

🎯 SpeedType — A Typing Speed Test in Java
A fun console app that tests how fast (and accurately) you can type a given sentence!


🚀 Why I Started This Challenge

Like many devs, I’ve watched tutorials, copied snippets, and built the usual calculator 10 times. But recently, I hit a plateau. I realized:

  • I was learning concepts but not really applying them.

  • I couldn't explain how things worked unless I Googled it first.

  • I lacked real hands-on projects in my resume and GitHub.

So I challenged myself:

✅ 30 Days
✅ 30 Java Projects
✅ Daily Learning + Blogging
✅ Share everything, including my bugs and breakthroughs.


🎯 What Is SpeedType?

It’s a console-based Java application that:

  • Displays a random sentence.

  • Starts a timer when the user begins typing.

  • Stops when the user hits enter.

  • Calculates typing speed in words-per-minute (WPM).

  • Checks accuracy by comparing input with the original sentence.


⚙️ How It Works (Under the Hood)

Let’s break down the logic:

  1. Display a Random Sentence

     String sentence = "Java is powerful and versatile!";
     System.out.println("Type this:\n" + sentence);
    
  2. Start Timer

     long startTime = System.currentTimeMillis();
    
  3. Take User Input

     Scanner sc = new Scanner(System.in);
     String typed = sc.nextLine();
    
  4. Stop Timer + Calculate Time Taken

     javaCopyEditlong endTime = System.currentTimeMillis();
     float seconds = (endTime - startTime) / 1000F;
    
  5. Count Words + Calculate Speed

     javaCopyEditint wordCount = typed.trim().split("\\s+").length;
     float wpm = (wordCount / seconds) * 60;
    
  6. Compare Accuracy

     javaCopyEditint correctChars = 0;
     for (int i = 0; i < Math.min(sentence.length(), typed.length()); i++) {
         if (sentence.charAt(i) == typed.charAt(i)) {
             correctChars++;
         }
     }
     float accuracy = (correctChars * 100.0f) / sentence.length();
    

🐞 The Problems I Faced

  1. Inaccurate Timing

    Initially, the timer would start before the user even saw the sentence — I had to shift the timer to begin after the prompt.

  2. String Comparison Logic

    I learned the hard way: == doesn't work for comparing strings in Java.
    I had to use .equals() or better, compare character-by-character for accuracy checking.

  3. Handling Extra Spaces

    Users may hit extra spaces — so I had to trim() the input and split with regex to get an accurate word count.

  4. Beginners Overthinking

    At one point, I thought of adding a full GUI with Swing. But the goal is learn and ship. I’ll upgrade in later projects.


📚 What I Learned

✅ How to use System.currentTimeMillis() for timing
✅ Working with Scanner and string manipulation
✅ String comparison and split("\\s+") tricks
✅ Balancing speed vs accuracy logic
✅ How to start simple, and ship fast


💬 Output Sample

yamlCopyEditType this:
Java is powerful and versatile!

You typed: Java is powerful and versitile!
Time Taken: 12.5 seconds
Speed: 19.2 WPM
Accuracy: 94.4%

🧑‍💻 Want to Join Me?

Whether you're a beginner or revisiting Java like I am — this challenge is for you!

Just pick a small idea daily, build it, and share your learning — trust me, the clarity and consistency will transform your coding habits.

🔗 I’ll be sharing daily projects, code snippets, and blogs right here on Hashnode.
You can follow me and tag your posts with #30DaysJavaRush or #30DaysOfCode.


🎁 Coming Up Tomorrow:

Day 2 — MindReader Game

A console game where the computer guesses the number you’re thinking.
(Spoiler: It’s all binary search! 🧠)


🙌 Final Words

Thanks for reading, and if you're struggling with consistency or feeling stuck — try this challenge. It’s fun, focused, and highly rewarding.

Let’s learn together. Drop your thoughts or link to your version in the comments 💬👇


🚀 GitHub Repo:

👉 https://github.com/Rushi-Unge/30Days30Projects

0
Subscribe to my newsletter

Read articles from Rushikesh Unge directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rushikesh Unge
Rushikesh Unge