Transcription of CSE 1321L - Assignment 1 - ccse.kennesaw.edu
1 CSE 1321L : Programming and Problem Solving I LabAssignment 1 100 pointsSolving ProblemsWhat students will learn:1) Problem solving2) Terminology3) Basic program structure4) Input and output with the user5) Basic calculations and those calculations requiring an intermediate solutionOverview: For most of you, this will be the first time you ve done any programming, which is exciting! The write-up of this first Assignment will be a little longer than others because we want you to have an understanding of how things are going to roll out the rest of the semester. Advice: Start early (certainly not the day the Assignment is due), practice, and ask a lot of questions. Unless calculations are trivial, you ll almost always want to use an intermediate variable where you store part of the solution. For example, you might remember the equation for gravity as: F=Gm1 m2R2 How would you write this as code?
2 You might solve it in parts instead of one shot because it makes it easier to check. It would look something like:MAINCREATE f1, m1, m2, r, g, temp1, temp2, temp3temp1 = m1 * m2temp2 = r * rtemp3 = temp1/temp2f1 = g * temp3 END MAINF inal note: don t cheat. If your temptation is to look online, don t. Come see us instead and ask questions we re here to help. Remember, you re going to have to write code in your future job interviews, so learn it now in order to secure a high-paying job : Math Mad Libs: In traditional Mad Libs, you re given a paragraph of text with blanks; you then fill in those blanks to create an amusing or silly story. In this program, we will do the same thing but with numbers!You will print out the following equation as a string literal:x + (y / z) * w = ?You will then prompt the user to enter one number at a time, replacing the variables from left to write with those numbers and printing the updated string to the screen.
3 After the last number is entered, you will print the full equation with the solution replacing the ? question sample output from this program is as shown below, with user input in bold. Your program s output must match this format, but it should work for any valid user input. Save your source code in a file called Assignment1A (with a file extension of .cpp, .cs or .java) Sample Output:[Math Mad Libs]x + (y / z) * w = ?Enter the first term: 33 + (y / z) * w = ?Enter the second term: + ( / z) * w = ?Enter the third term: -23 + ( / -2) * w = ?Enter the fourth term: + ( / -2) * = : Use a floating point variable to store each value entered by the user. Depending on your programming language, you may or may not have a decimal value displayed when entering a whole number (for instance, entering 5 may print out ).
4 Both formats are acceptable for this Assignment . Also, you can assume the user will not input 0 for the third term. We will learn how to handle logical issues like this a little later in the : Tipping Etiquette: It is customary in the United States to include a tip when purchasing a meal (or having one delivered). Recommendations for how much of a tip vary depending on who you ask, but the general range is somewhere between 10% on the low end and 20%. Since not everyone is great at calculating in their head, we re going to build a small program to show us the price with either a 10% or 20% tip will prompt the user to enter the following information: Total Price of the Meal Tax Rate (as a decimal value, not percentage) Delivery FeeYou will store these values in appropriate variables, and use them to produce the following intermediate values: Total Tax (Total Price of the Meal * Tax Rate) Subtotal (Total Price of the Meal + Delivery Fee) 10% Tip (Subtotal * 10%) 20% Tip (Subtotal * 20%) Total, 10% Tip (10% Tip + Subtotal + Total Tax) Total, 20% Tip (20% Tip + Subtotal + Total Tax)You will then print the results to the sample output from this program is as shown below, with user input in bold.
5 Your program s output must match this format, but it should work for any valid user input. Call the file Assignment1B (with a file extension of .cpp, .cs or .java) Sample Output: [Tip Calculator]Enter the total price of the meal: the local tax rate: the delivery fee: 10% tip would be $ total would be $ 20% tip would be $ total would be $ : As with Assignment1A, don t worry how many decimal places you have at this point (as long as the number is correct). We will cover rounding in a future C : Creating NetIDs! As a KSU student, you should have your own NetID the username you use to log into your email, D2L, and the lab computers among other KSU systems. While your real NetID is assigned to you by the school, in this program you will have the ability to generate and output your own custom NetID (for fun only, of course)!
6 The rules for a KSU NetID are as follows: First letter of your first name Your full last name A positive whole number, such as 12 The largest possible whole number value for this program is an example, a student named Scrappy Owl might have the NetID sowl1234. Your task for this Assignment is to prompt the user to enter the three pieces of required information. You must then store those values in the most efficient variable data type possible. You will not receive full points if you use a variable type that is larger than necessary consult the slides on data types to determine the best one for each : Each of the three user-inputted variables should have a different data the data has been entered and stored, you should concatenate the three values and print the results to the example of the program s output is shown below.
7 Your program s output must match this format, but it should work for any valid user input. Save your source code in a file called Assignment1C (with a file extension of .cpp, .cs or .java) Sample Output: [KSU NetID Generator]Enter the first letter of your first name: nEnter your last name: murphyEnter a valid whole number: 1 Your KSU NetID is nmurphy1. You can log into KSU computers with this NetID as your username and your email password as the email address is You will submit 3 separate files one for each of the assignments Upload separate files (one for each Assignment ) to the Assignment submission folder in Gradescope. Do NOT submit homework in Submit your work by the due date.