• 0

[NEWBIE] Project assignment question - Given an array of strings, output the total number (n) of characters in the list


Question

Hi all

 

I have a project assignment tomorrow at noon, call it homework. I have to write an algorithm, write the pseudocode and draw a flowchart.

 

Given an array of strings, output the total number [n] of characters in the list. Basically to count all the letters that occur in my string list. All the model algorithms similar I've found are counting the occurrences of a certain letter in the string. I don't need that, I just want the number of strings to be printed, but I don't have any restrictions how many times they should occur or not.

 

Example: a = ["Tom", "has", "books"] => n = 11; for a = [] (empty array, with no elements), n = 0.

 

I am a total beginner so bare with me.

 

I have found a javascript "pseudo"code that does what I need, but I have to translate this in a layman's pseudocode and draw a diagram.

String input = ["Tom", "has", "books"];

int count = 0;
for (int i=0; i<input.length(); i++) {
    if (input.charAt(i) != ' ') {
        ++count;
    }
}
System.out.println(count);

Muchos gracias.

 

kukubau

 

2 answers to this question

Recommended Posts

  • 0

"Light travels faster than sound. That's why some people appear bright until you hear them speak."

 

1. simply looking at a few posts would have informed you that help on homework is not likely to happen unless you are bright enough to phrase a question so it appears like a "real world" problem.

 

2. Flowcharts have not been spotted since the 1970's and those golden years of IBM Mainframes, so unless you own a T.A.R.D.I.S, and have a regular consulting gig back in the 1950's at UNIVAC, save some neurons and paper and aggravation and yeah there is always "that guy" who pulls out a flowchart in 2017 and everyone groans. Do you want to be That Guy?

 

3.  Pseudocode still has a tiny core of retro holdouts that are still trying to channel the spirit of PASCAL but unless you have a sister that cries a lot, do you really want to join the Lost Boys? (https://www.youtube.com/watch?v=mrMLMV6E4CM)

This topic is now closed to further replies.
  • Posts

    • Ridiculous claim that the labor cost difference of $6000 annually would increase cost per phone by $200. The employees produce 3 phones per month or what?
    • Sparkle 2.20.1 by Razvan Serea Sparkle is a free, open-source Windows optimization tool designed to make your PC faster, cleaner, and more private. With Sparkle, you can easily debloat Windows by removing unnecessary apps and services, disable Microsoft tracking to enhance privacy, and apply performance tweaks to boost speed. Its cleaner removes junk and temporary files, while every change is safe and fully reversible. Sparkle also features a modern, user-friendly interface with automatic updates, making system maintenance simple. Explore over 39 tweaks, from disabling telemetry and hibernation to optimizing network and game settings, all aimed at customizing and enhancing your Windows experience. Sparkle supports Windows 10 and 11. Sparkle 2.20.1 changelog: You can now change the Animation Direction from Up, Left, or Off. Added configurable animation direction (Up, Left, Off) for improved accessibility Added TTL caching to the system info backend Refactored tweak application flow to await NvidiaProfileInspector Improved IPC listener cleanup to correctly remove specific listeners Fixed online status not updating after successful network requests Updated system info tests to support backend caching Removed electron-toolkit utils dependency in favor of internal is.dev helper Fixed unwanted files and folders being included in application bundles Download: Sparkle 2.20.1 | Portable | ~100.0 MB (Open Source) Links: Sparkle Website | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Never used the G7 Pro, but I've never had a good experience with that style of d-pad and fighting games.
    • And I just bought a seat cushion for my mesh chair. The chair feels nice but the first time I sat in it with boxers, I realized I don't like the feel of mesh on my legs. 😂
    • "This Dell 27 inch 4K 120Hz IPS monitor is really cheap after a very long time" ... Lol.
  • Recent Achievements

    • One Month Later
      JKR earned a badge
      One Month Later
    • Dedicated
      Asgardi earned a badge
      Dedicated
    • Conversation Starter
      jessse3334 earned a badge
      Conversation Starter
    • Reacting Well
      JuvenileDelinquent earned a badge
      Reacting Well
    • One Month Later
      Excellence2025 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      496
    2. 2
      +Edouard
      251
    3. 3
      PsYcHoKiLLa
      154
    4. 4
      Steven P.
      86
    5. 5
      macoman
      65
  • Tell a friend

    Love Neowin? Tell a friend!