Methods Methods are bits of code that perform a specific task. This module teaches you how to define methods in your programs and uses the autograder to test if your methods are working correctly. Sign Up! Lesson 1: Java Methods. Lesson 2: Methods and Parameters. Methods and Parameters. Line Breaks with Parameters. Repeating Message. Lesson 3: Methods and Return Values. Methods and Return Values. Lesson 4: Javadocs and More Methods. Fahrenheit to Celsius.
Lesson 5: Strings Methods. Looping Over a String. Lesson 6: Strings and Characters. Strings and Characters. Chars are Numbers.
Character Methods. Is it an Integer? Lesson 7: Exceptions. Arithmetic Exception. Index Out Of Bounds Exception. Lesson 8: String Processing. String Processing. Finding Palindromes.
String Concatenation. Fix the Sum String. Convert To Uppercase. Do the Brackets Match?This is an awesome curriculum to inspire students in programming. All my students are engaged all the time. I've been teaching computer science for 9 years now and I've never seen this much engagement before. Sign Up. Comprehensive Teaching Platform. CodeHS has everything you need to teach computer science at your school, including web-based curriculum, teacher tools, administrator insights, and professional development.
The students say the class is "fun, fun, fun" and that the class period is too short. Learn What CodeHS is in 1 minute. Bottom line: This class is the talk of the school. CodeHS is trusted by thousands of teachers and schools all over the world for their classroom. Step-By-Step Curriculum. Help your students develop problem-solving and logical-thinking skills with our engaging and ready-to-use web-based curriculum.
Professional Development. Learn best practices for teaching computer science in a blended classroom. Connect with a community of teachers just like you. Great Teacher Tools and Resources. Everything you need to run your class, including rosters, progress tracking, syllabus, exercises, problem guides, lesson plans, and much more.
Amazing Support. Learning to code? Get programming help and unrivaled support from the CodeHS team. Join an online community of computer science teachers. Great Teacher Tools. Manage student rosters, track student progress, keep a syllabus, get detailed handouts and guides, and much more. Customize Your Class. Make it your own class with easy tools to create problems, autograders, quizzes, and more.
Time-Saving Autograding. We make it easy to grade problems both for functionality and style, and give you hooks to add your own autograders. Sign up. Get your students coding in under 5 minutes. Professional Development for Teachers. For district administrators, CodeHS is a silver bullet!As you have learned, a character is one of the primitive data types in Java.
We use the char keyword to declare it. A character is a single letter. It is great that we have an easy way to represent a single character, but what if we wanted to represent words or sentences? How can we do this? A String is a sequence of characters. We use Strings to represent full words and sentences. For example, the famous "Hello World" is a String. Some more examples of Strings:.
A String is not a primitive type like intcharbooleanand double are. Primitive types always start with lowercase letters, but a S tring starts with a capital letter. This makes it an object. You will learn more about objects in future chapters, but for now, it is important to just remember that a String is not a primitive type. Concatenate is a fancy word for joining or linking two things together. To concatenate two or more Strings means that you are joining them together to form one String.
After running the program, the concatenated String "McDonalds" gets printed to the screen. We are not limited to concatenating Strings with other Strings. We can concatenate Strings with other data types. Here we are concatenating a String and an integer together:. Look familiar? We have been doing this all the time in previous programs when printing out results to the screen! After running the program, we get:. You can also concatenate Strings with other primitive types like charbooleanand double.
In this program, we are comparing two Strings to determine if they are the same. We start by asking the user what the best programming website is. Their answer gets stored into the programmingWebsite String variable. We then attempt compare their answer with another String, "CodeHS". If they match, we congratulate them for making the right choice. If they don't match, we inform them that CodeHS is the best.
The dark mode beta is finally here. Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I have written a program with the method getSum int lower, int upperwhich returns the sum of the numbers between the lower and the upper bound inclusive.
I expect the answerand to see all the numbers printed as I add them up, but I get nothing printed at all. What have I done wrong? Note that this can be solved assuming no arithmentic overflow occurs for large input numbers or ranges without iterating using the equation:. Learn more. Asked 5 years, 2 months ago. Active 5 years, 2 months ago. Viewed 9k times. Andy Brown Masnad Hossain Masnad Hossain 59 1 1 silver badge 11 11 bronze badges. Define "not working". Active Oldest Votes. Andy Brown Andy Brown I just double checkedit runs smoothly but the sum right now while compiling goes up tillits not getting the range between them.
This method will return the sum of all numbers between and including lower and upper. You haven't clearly defined any other behaviour. If you want a different output then you need to define it in your question. What result do you expect to see?
Giulio Biagini Giulio Biagini 5 5 silver badges 8 8 bronze badges. Recursion like this is fine, but there is a limit to it. For a large enough range between lower and upperthis method will cause a fatal exception, called a StackOverflowExceptionwhich will terminate your program.
The exact stack depth that causes this depends on your JVM. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.CodeHS Answer - Key. Given a dictionary, build a function that returns a dictionary where the key 's and values are reversed.
Answer Question. CodeHS Java Libraries. View Documentation. Download this repository and source files. Active 5 months ago. Not the answer you're looking for? What are the answers for the 5. What is the answer to 3. What are the answers to 3. We wanted to let you know about the new teacher navigation that we recently introduced and give you a run down of the key components CodeHS lessons are Learn vocabulary, terms, and more with flashcards, games, and other study tools. I'm doing a simple program with Karel on codehs.
Thanks for contributing an answer CodeHS Curriculum and Syllabus.
Subscribe to RSS
This suggested syllabus is based on the CodeHS curriculum of introductory coding topics, and is designed for a high school class This is for the people who dont have the answers to codehs. I know your struggle. Codehs answer key keyword after analyzing the system lists the list of keywords related and the list of websites with related content, in addition you can see which CodeHS Answers 1. Become a Redditor. Then, return the filled parallel.
What is the answer to 4. What are the answers to 2. Sign Up, it unlocks CodeHS has everything you need to teach computer science at your school, including web-based curriculum, teacher tools, administrator insights, and It sparked The specific wording of the I think this answer violates the Community Guidelines. Chat or rant, adult content, spam, insulting other members,show more.Writing methods allows us to break our code into well-organized and reusable parts.
But sometimes we may want to reuse a method with a slight change.
CodeHS JavaControlStructure Answers
Notice that the code contains some repetition. In each case, we're adding Recall that methods are like blocks of code that do a particular thing. We can write a method that prints out "hello" when called, or a method that draws a circle. But what if we want to create a method to add ten to a number? We can sketch out the method like so:. We would expect an addTen method to add 10 to any number it is given. If we give it 3, the method will give us Were we to give it 32, it would give us The action that the addTen method takes is the same every time -- it adds 10 -- the only thing that changes is the number we give to the method.
The number that we pass to the method is called a parameter. Notice that there is an x that is being taken in and used by the method. This is the parameter. Its value will be whatever the user decides to "pass" to the method. Also note that the x parameter can be used like a regular variable in the body of the method. Now that the addTen method is defined, it's time to call the method. Let's first add ten to the number This works with variables as well.
The dark mode beta is finally here. Change your preferences any time.
Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. We have to remove all of one string from another string. You can assume that the second string is only one letter, like "a". We are expected to only have to use those 5 things to make it work. I attempted to write this program but my function doesn't do anything and I am really stumped.
Learn more. Asked 3 years, 2 months ago. Active 1 year, 4 months ago. Viewed 5k times. Active Oldest Votes. UnsignedByte UnsignedByte 6 6 silver badges 24 24 bronze badges. CBredlow 2, 2 2 gold badges 20 20 silver badges 42 42 bronze badges. Noah Serrault Noah Serrault 11 1 1 bronze badge.
Alastair Alastair 1 1 gold badge 6 6 silver badges 18 18 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. The Overflow How many jobs can be done at home? Featured on Meta. Community and Moderator guidelines for escalating issues via new response….
Feedback on Q2 Community Roadmap. Technical site integration observational experiment live on Stack Overflow. Triage needs to be fixed urgently, and users need to be notified upon….
Dark Mode Beta - help us root out low-contrast and un-converted bits. Related