• 0

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


Question

kukubau

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

 

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0
DevTech

"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)

Link to post
Share on other sites
  • 0
kukubau

You sir made my day. :))

Link to post
Share on other sites
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By News Staff
      Save 94% off a lifetime membership to Whizlabs Online Certifications
      by Steven Parker



      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can save 94% off a lifetime membership to Whizlabs Online Certifications. Get lifetime access to affordable world-class certification training courses and gain new, essential industry skills.

      Are you a practicing professional but wanting to learn more? Learn new skills and knowledge at your own pace with Whizlabs. Whizlabs is a pioneer among online training providers across the world. They provide online certification training in various disciplines such as Cloud Computing, Java, Big Data, Project Management, Agile, Linux, CCNA, and Digital Marketing. Launched in 2000, Whizlabs has helped more than 3 million professionals and 100+ companies across the world to succeed in their careers with multitudes of courses. If you want to boost your career or grow in your current field, then sign up to Whizlabs now!

      Access various courses on AWS, Microsoft, Google Cloud, Java, Linux & more Get certifications & validate and demonstrate your new skills Learn from subject-matter experts & certified professionals Get regularly updated content What's the benefit?
      Lifetime membership to Whizlabs Online Certifications normally costs $4,499, but you can pick it up for just $239.99 for a limited time - that represents a saving of $4,259.01 (94%) off. For a full description, specs, and instructor info, click the link below.

      Save 94% off a lifetime membership to Whizlabs
      Not for you?
      That's OK, there are other deals on offer you can check out here.



      Enter giveaways: Polycade Home Arcade | $5K in cash | $10K in Crypto Ivacy VPN - 5 year subscription for just $1 per month NordVPN - 2 year subscription at up to 68% off Private Internet Access VPN - subscriptions at up to 71% off Unlocator VPN or SmartDNS - unblock Geoblock with 7-day free trial Neowin Store for our preferred partners. Subscribe to Neowin - for $14 a year, or $28 a year for Ad-Free experience Disable Sponsored posts · Neowin Deals · Free eBooks · Neowin Store

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs.

    • By News Staff
      Pay What You Want for this Java Master Class Bundle
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where for only a limited time you can Pay What You Want for this Java Master Class Bundle. Kickstart your coding career with 50+ hours of training in the world's most popular programming language.



      With the Pay What You Want bundles, you can get something incredible for as little as you want to pay. And if you beat the average price, you’ll receive the fully upgraded bundle! Included in this Pay What You Want deal, are the following courses:

      Pay What You Want (as little as $1) for the unlocked item:

      Java Game Development: Create a Flappy Bird Clone
      Use the World's Most Popular Programming Language to Create Your First Game

      Or beat the average price to also get the following items:

      Oracle Java SE 8 Certification Course
      Get Your Java Skills Online in This 14-Hour Primer

      Java Web Services and XML: ORACLE Exam Preparation
      Enhance Your Java Toolkit with an Introduction to XML

      JavaFX: Building Client Applications
      Walk Through Building Your First JavaFX App in 3 Hours

      Mastering Java Swing & GUI Applications
      Learn How to Write GUI Applications in Java

      Java Web Technologies Course
      Get Java-Savvy & Prep for an Oracle Certification Exam

      Professional Web Scraping with Java
      Collect Mounds of Valuable Data by Web Scraping

      Java Hibernate Object/Relational Mapping (ORM) Course
      Come to Grips with Java's Hibernate Tool

      Java Spring MVC Quickstart Course
      Create Web Apps Using the Java Spring Framework

      Learn Java From Scratch
      Go From Beginner to Expert in the Web's Most Popular Language - Over 9 Hours of Training

      What's the benefit?
      The bundle represents an overall retail value of $960 But you can Pay What You Want for the unlocked course (as little as $1) Beat the average price and you'll take home the entire bundle. Beat the Leader's price and get entered into the epic giveaway. Pay What You Want for this Java Master Class Bundle
      See other Pay What You Want deals This is a time-limited deal that ends soon.
      Get $1 credit for every $25 spent · Give $10, Get $10 · 10% off for first-time buyers.

      Not for you?
      That's OK, there are other deals on offer you can check out here.



      Enter giveaways: Polycade Home Arcade | $5K in cash | $10K in Crypto Ivacy VPN - 5 year subscription for just $1 per month NordVPN - 2 year subscription at up to 68% off Private Internet Access VPN - subscriptions at up to 71% off Unlocator VPN or SmartDNS - unblock Geoblock with 7-day free trial Neowin Store for our preferred partners. Subscribe to Neowin - for $14 a year, or $28 a year for Ad-Free experience Disable Sponsored posts · Neowin Deals · Free eBooks · Neowin Store

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs.

    • By News Staff
      Save 98% off a lifetime membership to Whizlabs Online Certifications
      by Steven Parker

      Today's highlighted deal comes via our Online Courses section of the Neowin Deals store, where you can save 97% off a lifetime membership to Whizlabs Online Certifications. Get lifetime access to affordable world-class certification training courses and gain new, essential industry skills.



      Are you a practicing professional but wanting to learn more? Learn new skills and knowledge at your own pace with Whizlabs. Whizlabs is a pioneer among online training providers across the world. They provide online certification training in various disciplines such as Cloud Computing, Java, Big Data, Project Management, Agile, Linux, CCNA, and Digital Marketing. Launched in 2000, Whizlabs has helped more than 3 million professionals and 100+ companies across the world to succeed in their careers with multitudes of courses. If you want to boost your career or grow in your current field, then sign up to Whizlabs now!

      Access various courses on AWS, Microsoft, Google Cloud, Java, Linux & more Get certifications & validate and demonstrate your new skills Learn from subject-matter experts & certified professionals Get regularly updated content Good to know
      Length of time users can access this course: lifetime This plan is only available to new users Redemption deadline: redeem your code within 30 days of purchase For a full description, specs, and instructor info, click here.

      What's the benefit?
      Lifetime membership to Whizlabs Online Certifications normally costs* $4,499, but you can pick it up for just $129.99 for a limited time - that represents a saving of $4,369.01 (97%) off.

      Spring Sale Promo
      Ends today April 13, for every $75 spent, get $10 in store credit.

      Get this deal, or learn more about it
      See all discounted Online Courses. This is a time-limited offer.
      Get $1 credit for every $25 spent · Give $10, Get $10 · 10% off for first-time buyers.

      Not for you?
      That's OK, there are other free eBooks on offer you can check out here.



      Enter giveaways: Polycade Home Arcade | $5K in cash | $10K in Crypto Ivacy VPN - 5 year subscription for just $1 per month NordVPN - 2 year subscription at up to 68% off Private Internet Access VPN - subscriptions at up to 71% off Unlocator VPN or SmartDNS - unblock Geoblock with 7-day free trial Neowin Store for our preferred partners. Subscribe to Neowin - for $14 a year, or $28 a year for Ad-Free experience Disable Sponsored posts · Neowin Deals · Free eBooks · Neowin Store

      Disclosure: A valid email address is required to fulfill your request. Complete and verifiable information is required in order to receive this offer. By submitting a request, your information is subject to TradePub.com's Privacy Policy.

    • By zikalify
      U.S. Supreme Court sides with Google in Java dispute
      by Paul Hill



      The United States Supreme Court has sided with Google over its use of a Java API which Oracle argued it owned the copyright to. The long-running battle has been going on for nearly 11 years now after Oracle opened fire by suing Google. Over the years, the dispute has been through a range of courts with various judges ruling for this side and that but today’s decision should be more final.

      According to the document published by the Supreme Court, Google copied 11,500 lines of code from a Java API (Application Programming Interface). The court decided that this was allowed under fair use because it was needed to allow programmers to “put their accrued talents to work in a new and transformative program”.

      On the 44th page of the document, Justice Clarence Thomas dissenting in favour of Oracle said that Google initially sought to license the code for use in Android but after the two couldn’t agree on terms Google simply copied the 11,500 lines of code “verbatim”. He said that this wiped out 97.5% of the value of Oracle’s partnership with Amazon and helped Google establish itself as the owner of the biggest mobile operating system in the world.

      Despite the win today for Google, the firm has been very busy for the last several years actively promoting Kotlin for use in building Android apps. The company has also been building a new operating system called Fuchsia OS which could ultimately replace Android and put the whole argument over Java to bed once and for all.

    • By News Staff
      Pay What You Want for this Complete Learn to Code Certification Bundle
      by Steven Parker

      Today's highlighted offer comes via our Online Courses section of the Neowin Deals store, where you can Pay What You Want for the Complete Learn to Code Certification Bundle. A price you pick gets you 156 hours of premium coding instruction, from Python to Ruby and everything in between.



      With the Pay What You Want bundles, you can get something incredible for as little as you want to pay. And if you beat the average price, you’ll receive the fully upgraded bundle! Included in this Pay What You Want deal, are the following courses:

      Pay What You Want (as little as $1) for the unlocked course:

      JavaScript Programming Complete
      Work Towards a Lucrative Career in Web Development by Building Real-World JavaScript Projects Or beat the the average price to get these as well:

      Learn How To Code: Google's Go Programming Language
      Go is an open source programming language developed by Google that makes it easy to build simple, reliable, and efficient software. The Complete Python Course: Beginner to Advanced!
      Get the Complete A to Z Story on Python & Start Building Advanced Programs Fast

      Learn By Example: Scala
      Master This Highly Scalable General-Purpose Language with 65 Examples

      Projects in Programming Languages: Ruby, Python, Java
      Learn 3 of the Most Financially Viable Programming Languages by Solving Real-World Problems

      Learn Angular 2 from Beginner to Advanced
      Use the Newest Version of this Powerful Google Framework to Build Complex Apps

      How to Make a Freaking iPhone App: iOS 10 and Swift 3
      Nail Down the Development Fundamentals of the Hottest New OS

      The Complete Web Developer Masterclass: Beginner To Advanced
      Become an Employable Web Developer by Learning HTML, JavaScript, Angular, NodeJS, & Much More

      Git Complete Mastery & GitHub: 100% Hands-on Git Guide
      Develop a Rock Solid Foundation in Git & Start Building Programs More Efficiently

      Professional Rails Code Along
      Develop a Real World Rails Project Through a Step-by-Step Process

      Good to know:
      The bundle represents an overall retail value of $1,573 But you can Pay What You Want for the two unlocked courses (as little as $1) Beat the average price and you'll take home the entire bundle. Beat the Leader's price and get entered into the epic giveaway. Pay What You Want for the Complete Learn to Code Certification Bundle
      See other Pay What You Want deals. This is a time limited deal.
      Get $1 credit for every $25 spent · Give $10, Get $10 · 10% off for first-time buyers.

      Not for you?
      That's OK, there are other deals on offer you can check out here.



      Giveaways: Home Arcade Polycade | Complete Home Gym | $10K in Crypto currency Ivacy VPN - 5 year subscription for just $1 per month NordVPN - 2 year subscription at up to 68% off Private Internet Access VPN - subscriptions at up to 71% off Unlocator VPN or SmartDNS - unblock Geoblock with 7-day free trial Neowin Store for our preferred partners. Subscribe to Neowin - for $14 a year, or $28 a year for Ad-Free experience Disable Sponsored posts · Neowin Deals · Free eBooks · Neowin Store

      Disclosure: This is a StackCommerce deal or giveaway in partnership with Neowin; an account at StackCommerce is required to participate in any deals or giveaways. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through our branded deals site, and it all goes toward the running costs.