This is an individual assignment. You must complete this lab on your own, although you may discuss lab concepts with other students. Please keep the Academic Integrity Policy in mind---do not show your code to anyone outside of the professors and ninjas, and do not look at anyone else's code for this lab. If you need help, please post a question on Piazza, or contact the professor.
The goal of this lab is to introduce you to basic concepts in the C++ program language. Concepts you will be familiar with after this lab include:
Create a new project called lastname_PrgAsst1.
When submitting your assignment on onCourse, you should submit a .zip file of the entire folder for the project.
Take some text. Put a small ball at the top of the first letter of the first word of the first sentence. The ball is drawn via gravity downwards. The text is also at a slight angle, so the ball wants to also move towards the right. You can assume that the ball can freely move between the lines, can drop through spaces, and all characters have the same width. Considering the first column to be column 0, what column will the ball end up in? In this example, the ball ends up in column 7.
The input will consist of lines of text entered by the user. You can assume that the user will enter no more than 100 lines, so that you can store all the lines in an array of strings of size 100. You can assume that the lines contain no special characters, only letters, digits and spaces.
At the end of the program, prints on screen: "The ball will fall on column: " followed by a single integer indicating the column from which the ball will drop.
For example:
Enjoy!
Your program should print a line on screen asking the user to enter their text, then let the user enter as many lines of text as they want. The user will signal that they are done entering text by entering an empty line.
Your program should assume that the user will not enter more than 100 lines, but the program should work if the user enters 0 lines (that is, the first line the user enters is an empty line) and the program should also work if the user enters 100 lines (meaning line 101 is an empty line). Your program does not have to detect if the user enters more than 100 lines, in that case, the program can behave arbitrarily, you do not have to handle this case.
Your program should print EXACTLY the words The ball will fall on column: followed by a space followed by the number of the column.
Any deviation from this output format will result in the loss of a few style points.
Go to the web site HackerRank and complete every section of the introductory sequence. When signing up, click the option to connect using a Google account and use your wheatoncollege.edu email.
You can wait a bit before completing the sections on pointers and dynamic arrays, we should see those in class by the end of this week.
Once you are done with these exercises, select the "Strings" subdomain at the right of the screen and complete the section called "Strings". You can ignore the sections called "StringStream" and "Attribute Parser".
When you are done with all the exercises, come to me in person and show me that you have solved all the required sections. I will not explicitly grade your solutions, but completing these exercises will count towards the "Lab Exercises and Written Assignments" of your grade in this course.
The text for these exercises introduce functions called printf and scanf. You can ignore that text and use cin and cout instead. However, in the exercise about "Basic Data Types", the exercise will not be corrected properly if you use cout to display a float or double because printf and cout have different default precisions when printing a result (and the grading tool is dumb). To complete these exercise, you can just use the following code to print floats and doubles, you do not have to understand how this works.
float a; double b; ... // prints a single float variable: printf("%f", a); // prints a single double variable: printf("%lf", b);
This problem is based off of problem 6545 from the ACM-ICPC live archive.