The following pseudocode describes how to obtain the name of a day, given the day number (0 = Sunday, 1 = Monday, and so on.)
Declare a string called names containing "Sun MonTueWedThuFriSat".
Compute the starting position as 3 x the day number.
Extract the substring of names at the starting position with length 3.
Check this pseudocode, using the day number 4. Draw a diagram of the string that is being computed, similar to Figure 3.
Want to see the full answer?
Check out a sample textbook solutionChapter 2 Solutions
BIG JAVA: LATE OBJECTS
Additional Engineering Textbook Solutions
Using MIS (10th Edition)
Digital Fundamentals (11th Edition)
Starting Out with Python (3rd Edition)
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
- public static String pancakeScramble(String text) This nifty little problem is taken from the excellent Wolfram Challenges problem site where you can also see examples of what the result should be for various arguments. Given a text string, construct a new string by reversing its first two characters, then reversing the first three characters of that, and so on, until the last round where you reverse your entire current stringarrow_forwardWrite phython code A ball of mass 5kg is located at position m. It is fired vertically upward with an initial velocity of v= m/s. Due to Moon's gravitational force acting on the object, it reaches a maximum height and falls back to the ground (since we cannot represent infinite ground, use a large thin box for it). Simulate the motion of the ball. Print the maximum height that the object reaches. Create a ball and the ground using the provided specifications. Write a loop to determine the motion of the object until it comes back to its initial position. Plot the graph on how the velocity of the object changes along the y-axis with respect to time..arrow_forwardOne interesting application of computers is drawing graphs and bar charts (sometimes called histograms). Write a script that reads five numbers between 1 and 30. For each number read, output HTML5 text that displays a line containing the same number of adjacent asterisks. For ex- ample, if your program reads the number 7, it should output HTML5 text that displays *******.arrow_forward
- City and State. Extract the city name and state from strings like “Utica, NY” and “Los Angeles, CA”. Assume the state is always the last two characters in the string, the city name has at least one character, there is a comma following the city name, and a single space after the comma. Use the split method to separate the city name from the state (Notice the city name will still have a comma at the end). The following attachement is a sample execution:arrow_forwardA right triangle can have sides that are all integers. The set of three integer values for the sides of a right triangle is called a Pythagorean triple. These three sides must satisfy the relationship that the sum of the squares of two of the sides is equal to the square of the hypotenuse. Write a program to find all Pythagorean triples for side1, side2, and the hypotenuse all no larger than 30. Use a triple-nested for loop that simply tries all possibilities. Using Files in c programming language and comment all your steps pleasearrow_forwardin C# language thank you.arrow_forward
- Given a string str, find the length of the longest substring without repeating characters. (a).For “ABDEFGABEF”, the longest substring are “BDEFGA” and “DEFGAB”, with length 6. (b).For “BBBB” the longest substring is “B”, with length 1.For “GEEKSFORGEEKS”, (c).there are two longest substrings shown in the below diagrams, with length 7 write code in pythonarrow_forwardA very known application in natural language processing is to extract information from a given text. In this lab, you will be able to extract some emotions (Sad and Happy) from a given string and calculate the score of each emotion. You will be given below the words that express sadness, anger, and happiness. For each word, you will be given weight as well, so that when you are calculating for example the score for sadness in the text (string), you can use this formula:arrow_forwardWrite a program that reads a string and checks the longest substring starting with "a" and ending with "z" included in it. Note that, the substring cannot contain another a or another z in it. For example: Ifs="bcd bbccdd badefgze tabdz", the longest substring is: 6arrow_forward
- Try to do asap And do not copy from other sources Write your own code with necessary comments.arrow_forwardGiven a string, find the first non-repeating character in it and return it'sindex. If it doesn't exist, return -1.For example:s = "leetcode"return 0.s = "loveleetcode",return 2..arrow_forwardComputer sciencearrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education