Search on any assignment and view the sample code if provided by the author.
To edit an assigment check the box for that assignment and click Edit a Assignment.
| Database ID | Language | Topic | Difficulty | Title | Description | |
|---|---|---|---|---|---|---|
| 4 | Python | Output | Low | ASCII Art | ASCII art is defined by Britannica as a type of computer text art that uses characters from the American Standard Code for Information Interchange (ASCII) to create images. If the following site does not work, then tell them to perform a web search on 'ASCII art'. Some ASCII art can be really simple (a few lines) and other ASCII art can be really complex, so I suggest telling students pick art that is between 10 to 20 lines. | |
| 3 | Python | Output | Low | Escape Sequences | Write a program that will use two or more escape sequences to output the following phrase. To make every students code a little unique have the students fill in the the applicable text between<FILL IN THE BLANK>. | |
| 2 | Python | Output | Low | Initials | Write a program to display your initials for your first name, middle name, and last name (ex. CEB). Use the letters in your initials to form each letter of your initials, for example see how JAVA is spelled in the following pattern with 'J' for the letter J, 'a' for the letter a, and etc. | |
| 5 | Python | Output | Low | Shape | Create a program that will draw two filled-in shapes (other than squares or rectangles) and use print statements to output the shaped. Shapes should be 10 or more lines. | |
| 9 | Python | Variables | Medium | Reverse the Numbers | Write a program to reverse the digits of a given integer. <ul> <li>User input to get a three digit number (ex. 100 to 999).</li> <li>Save the input to a variable.</li> <li>Break the input into the hundreds place, tens place, and ones place.</li> <li>Use math operations to reverse the number.</li> </ul> <br> <b>NOTE:</b> You MUST use math operators to solve this problem. Do NOT use String methods. | |
| 11 | Python | Variables | Medium | Surface Area | Write a program to calculate the Surface Area of a Cylinder: <br> <br> The surface area of a cylinder can be calculated using the formula: <br> <b>A = 2πrh + 2 πr<sup>2</sup></b> <ul> <li>Prompt the user for the radius of the cylinder.</li> <li>Prompt the user for the height of the cylinder.</li> <li>Format the output to 2 decimal places.</li> </ul> | |
| 10 | Python | Variables | Medium | BMI | Write a program to calculate a users Body Mass Index (BMI) using the following formula:<br> <b>weight (lb) / [height (in)]2 x 703</b> <ul> <li>Prompt the user for their weight in pounds (lb) and ounces (oz).Ounces (oz) must be changed to decimal values (NOTE: 1 lb = 16 oz)</li> <li>Prompt the user for their height in inches.</li> <li>Output the users BMI.</li> <li>Round the answer to two decimal places (see output).</li> </ul> <b>Example</b> Let’s calculate Sam’s BMI using the English numeric system. His weight is 37 pounds and 4 ounces and his height is 41 1/2 inches. <br> <br> Convert ounces and fractions to decimals: <br> <ul> <li>Weight of 37 lbs and 4 oz = 37.25 lbs (16 ounces = 1 pound so 4 oz/16 oz = 0.25).</li> <li>Height = 41.5 in.</li> <li>(37.25 lbs / 41.5 in / 41.5 in) x 703 = 15.2</li> </ul> | |
| 1 | Python | Output | Low | Poem | Look up a poem (at least 6 lines long) and print out the poem using both double quotation marks, single quotation marks, and indent / tab every other line.<br> <br> <b>Topics Explored</b> <ul> <li>Print Statements</li> <li>Escape Sequences</li> </ul> | |
| 6 | Python | Variables | Low | Utensils | Camryn is unpacking a box of utensils. The total weight of the box of utensils is <em>x</em> lbs and it contains <em>x</em> forks.<br> <ul> <li>Have user input to enter the weight of each box</li> <li>Have user input to enter the number of utensils in each box</li> </ul> What is the weight of each fork?<br> <br> <b>Topics Covered</b> <ul> <li>User input</li> <li>Division</li> <li>Outputting text and variable values</li> </ul> | |
| 12 | Python | Conditionals | Low | Equal To, Greater Than, or Less Than | Write a program to accept two integers and check whether they are equal to, greater than, or less than each other. <br> <ul> <li><b>NOTE:</b> The output needs to match the following structure: number 1 is greater / less / equal to / than number 2</li> </ul> | |
| 14 | Python | Conditionals | Low | Weather | Write a program to prompt a user for a temperature in Fahrenheit and display a suitable message according to the temperature state below: <br> <ul> <li>Temp < 32: Freezing Weather</li> <li>Temp 32 - 45: Very Cold Weather</li> <li>Temp 46 - 60: Cold Weather</li> <li>Temp 61 - 79: Moderate Weather</li> <li>Temp 80 - 89: Hot Weather</li> <li>Temp >= 90: Very Hot</li> </ul> | |
| 15 | Python | Conditionals | Medium | Days in a month | Write a program to find the number of days in a month (including leap years). <br> <ul> <li>Prompt the user for the month.</li> <li>If the month is February then prompt the user for the year.</li> <li>Handle the following leap years: 2020, 2024, 2028, 2032</li> </ul> <em>Thirty days hath September, April, June, and November; All the rest have thirty-one, Excepting February alone, And that has twenty-eight days clear.</em> | |
| 17 | Python | Conditionals | Medium | Form Triangle | Write a program to check whether a triangle can be formed based upon three values entered by a user for the angles. <br> <br> To check if a triangle can be formed with given side lengths, use the "Triangle Inequality Theorem": add any two side lengths together, and if the sum is greater than the third side length, then a triangle can be formed. <br> <br> <b>NOTE:</b> You have to add up all combination of sides to determine if a triangle can be formed. <ul> <li>Prompt the user for three values.</li> <li>If the triangle can be formed output: "A triangle can be formed"</li> <li>If the triangle cannot be formed output: "A triangle cannot be formed"</li> </ul> | |
| 16 | Python | Conditionals | High | Clothing Discount | Write a program to determine if the total amount of a sale should be discounted. If the amount is greater than $100, then the amount is discounted by 5%. If the sale is greater than $150 then the amount of the discount is 10%. <br> <br> At the store shoppers are only allowed to buy 5 things at a time and the following items are sold: <ul> <li>Short Sleeve Shirts $10</li> <li>Long Sleeve Shirts: $15</li> <li>Jeans: $30</li> <li>Cargo Pants: $30</li> <li>Jackets: $50</li> <li>Dresses: $35</li> </ul> | |
| 27 | Python | Strings | Low | Lowercase and Uppercase | Based upon user input of a sentence, replace lowercase characters with uppercase and vice versa. <br> <ul> <li>If the user does not enter a multi-word sentence, re-prompt the user for a new sentence.</li> </ul> | |
| 30 | Python | Strings | Medium | Longest and Shortest Word | Write a program that prompts a user for a sentence. Find the largest and smallest words in the sentence. <br> <ul> <li>Re-prompt the user if they did not enter two or more words.</li> <li>If two words are the same length output the first word from left to right.</li> <li>Spaces and special characters do NOT count as the smallest characters.</li> </ul> | |
| 31 | Python | Strings | High | How Many Times | <b>NOTE:</b> Do not use lists / arrays to solve this. Just use String methods, loops, and conditionals <br> <br> <b>NOTE:</b> The count() function will find every occurrence of a word, even if it part of another word (ex. he is found in the, shell, etc.). Instead to pass all the tests students will need to look at each individual word. <br> <br> Prompt the user for a sentence and a word to find. Output the number of times that the word to find appears in the sentence as its own word. <br> <ul> <li>Ignore case sensitivity (i.e. "H" and "h" should be treated as the same character).</li> <li>If the word is not in the sentence then output: "Word not found"</li> </ul> | |
| 7 | Python | Variables | Low | Moving | Carrie is packing to move to another apartment down the hall. She packed <em>x</em> boxes. Each box can hold up to <em>z</em> lbs. The trolley she is using to move can take up to 32 lbs. How many trips does it take her to move if she only has one trolley? <br> <br> <b>Topics Covered</b> <ul> <li>User input</li> <li>Division</li> </ul> | |
| 8 | Python | Variables | Low | Office Supplies | An office supply company truck can take up to x lbs of cargo. Oliver packed z boxes; each box can weigh up to 34 lbs. After Oliver loaded all the boxes, the truck can take about ___________ lbs more of cargo?<br> <br> <ul> <li>Get user input to determine how much cargo the office supply truck can hold.</li> <li>Get user input to determine how many boxes Oliver packed.</li> <li>Format the output with commas (see output example).</li> </ul> From the same office supply company, Hannah ordered some office supplies. When the supplies were delivered, they came in 2 boxes. The total weight of the two boxes was 44 lbs. What is the individual weight of the two boxes, assuming one of the boxes was at max weight? | |
| 13 | Python | Conditionals | Low | Largest of Three Numbers | Write a program to find the largest of three numbers. The numbers can be typed in any order (i.e. smallest to largest, largest to smallest, or the largest number in the middle). <br> <ul> <li>Prompt the user for three numbers</li> <li>Output the largest of the three numbers</li> </ul> | |
| 18 | Python | Conditionals | Medium | Electric Bill | Write a program to calculate and print the electricity bill of a given customer. Prompt the user for their customer ID, name, and unit consumed by the user. Output the total amount to be paid to the customer. <br> <br> The charge are as follow : <table style="border: 1px solid black; width:100%"> <tr> <td style="border: 1px solid black;"><b>Unit</b></td> <td style="border: 1px solid black;"><b>Charge / Unit</b></td> </tr> <tr> <td style="border: 1px solid black;">up to 199</td> <td style="border: 1px solid black;">@1.30</td> </tr> <tr> <td style="border: 1px solid black;">200 - 399</td> <td style="border: 1px solid black;">@1.60</td> </tr> <tr> <td style="border: 1px solid black;">400 - 599</td> <td style="border: 1px solid black;">@1.90</td> </tr> <tr> <td style="border: 1px solid black;">600 and above</td> <td style="border: 1px solid black;">@2.10</td> </tr> </table> <br> <b>NOTE:</b> If bill exceeds 400 units then a surcharge of 15% will be charged based upon the total bill and the minimum bill should be of 100 units. | |
| 29 | Python | Strings | Low | Short + Long + Short | Write a program that prompts a user for two strings. Determine the length of the two strings and output a string in the following order: short + long + short <br> <ul> <li>Verify that the strings are not the same length. If they are the same length then re-prompt the user for two new words.</li> <li>If either of the strings are empty, then re-prompt the user for new words.</li> </ul> | |
| 32 | Python | Strings | Medium | Type of Characters | <b>NOTE:</b> Do not use lists / arrays to solve this. Just use String methods, loops, and conditionals. <br> <br> Prompt the user for a String and count the total number of alphabets, digits and special characters in a string. <br> <ul> <li>Alpha characters are a - z or A - Z</li> <li>Digits are 0 - 9</li> <li>Special Characters are !, @, #, $, %, ^, &, *, .</li> <li>Ignore spaces</li> </ul> <br> <b>Sample Code - isalpha() and isdigit() Methods</b> <br> <code> txt = "Hello" <br> txt.isalpha() <br> <br> nbr = 12345 <br> nbr.isdigit() </code> | |
| 54 | Java | Variables | Medium | Project | Create a Project application to help analyze the time taken for a Java project. <br> <br> The application should prompt you for the time spent designing, coding, debugging, and testing, and then displays a table showing the percentage of time taken for each part. <br> <br> <b>NOTE: </b>Use the getPercentInstance() format to format the percentage for each part of the project. | |
| 19 | Python | Conditionals | Medium | Course Eligibility | Write a program to determine eligibility for admission to an upper level programming course based on the following criteria:<br> <br> Eligibility Criteria : <ul> <li>Marks in Algebra 1 >= 65 and Marks in Programming Fundamentals >= 70 and Marks in AP Computer Science Principles >= 70 and Total in all three subjects >= 210</li> </ul> OR <ul> <li>Total in Algebra I, Geometry, Algebra II and Marks in Programming Fundamentals >= 140</li> </ul> Prompt the user for the following grades: <br> <br> <b>NOTE:</b> If they have not taken a course then enter a 0 <ul> <li>Algebra I</li> <li>Geometry</li> <li>Algebra II</li> <li>Programming Fundamentals</li> <li>AP Computer Science Principles</li> </ul> Output the following: <br> <ul> <li>Candidate is eligible</li> <li>Candidate is not eligible</li> </ul> | |
| 20 | Python | Conditionals | High | Date of the Bunny | Implement the calculator for the date of the bunny. <br> <br> The following algorithm computes the date of Bunny Sunday for any year between 1900 to 2099. <br> <br> Ask the user to enter a year. Compute the following: <ul> <li>a = year % 19</li> <li>b = year % 4</li> <li>c = year % 7</li> <li>d = (19 * a + 24) % 30</li> <li>e = (2 * b + 4 * c + 6 * d + 5) % 7</li> <li>dateofbunny = 22 + d + e</li> </ul> More pieces to implement: <br> <ul> <li>If you subtract dateofbunny - 31 you will get the exact date for that year if the dayofbunny is greater than 31</li> <li>The exception is for four special years (1954, 1981, 2049, or 2076) then subtract 7 from the date as well.</li> <li>Output the correct ending for the number (ex 19th):</li> <ul> <li>If the number ends in 1, the suffix is –st.</li> <li>If the number ends in 2, the suffix is –nd.</li> <li>If the number ends in 3, the suffix is –rd.</li> <li>If the number ends in 4-9, the suffix is –th.</li> <li>If the number is a multiple of 10, the suffix is –th.</li> <li>The numbers 11-19 also use the suffix –th.</li> </ul> </ul> Your program should print an error message if: <ul> <li>The user provides a date that is out of range then print: "Year out of range"</li> <li>If the user does not enter a date (i.e. a String) then print: "Not a number"</li> </ul> | |
| 21 | Python | Conditionals | Medium | Your Height | Prompt the user for their height in feet and inches, then provide them a menu option to calculate their height in either meters or centimeters. Output their height based upon the menu option chosen. <br> <ul> <li>12 inches in a foot</li> <li>1 inch equals approximately 0.0254 meters</li> <li>1 inch equals approximately 2.54 centimeters</li> </ul> <br> Additional Programming notes: <br> <ul> <li>Round your output to 2 decimal places</li> <li>Handle if the user does not enter a number in any of the inputs</li> <li>Handle if the user enters a menu option that does not exist<li> </ul> | |
| 22 | Python | Iteration | Low | Sum of Numbers | Using a loop write a program to have the user input 5 numbers (prompt them each time for each number) and find the sum and average of the numbers. | |
| 23 | Python | Iteration | Low | Cube | Write a program to display the cube of x numbers up to an inputted number.<br> <br> Cubed Formula: 2 x 2 x 2 = 8<br> <br> <b>NOTE</b>: Your output must match the example output below. | |
| 24 | Python | Iteration | Low | Number Nine | Write a program to find the numbers of all integers within the range specified by a user, which are evenly divisible by 9. <br> <ul> <li>Prompt the user for the beginning and ending range.</li> <li>Output all numbers that are evenly divisible by 9 in one line.</li> <li>Output the sum of the numbers that are evenly divisible by 9 on its own line. Don't forget the commas.</li> </ul> | |
| 25 | Python | Iteration | Medium | Right Triangle | Write a program to make a right angle triangle with the number increased by 1 using a loop. <br> <ul> <li>Prompt the user for the number of rows and draw a right triangle with that number of rows</li> <li><b>HINT:</b> Outer and Inner loop is the best way to solve this problem.</li> </ul> | |
| 26 | Python | Strings | Low | First & Last Character | Write a program to prompt the user for a word. Take the inputted word / string and if the word is 5 or more characters only output the first 3 and last 2 characters of a given string. If the string length is less than 5, print the original string instead. <ul> <li>Prompt the user for a word.</li> </ul> | |
| 55 | Java | Variables | Medium | Gallon Converter | Create a GallonConverter application that prompts the user for the number of gallons and then displays the number of quarts, pints, cups, and tablespoons in that number of gallons. <br> <ul> <li>In a gallon, there are four quarts.</li> <li>In a quart, there are two pints</li> <li>In a pint, there are two cups</li> <li>In a cup there are sixteen tablespoons</li> </ul> <b>NOTE: </b>Use double as your variable types. | |
| 28 | Python | Strings | Medium | Replacing Characters | Write a program to replace specified characters with another character. <br> <ul> <li>First prompt the user for a 5 letter or more word.</li> <li>Have error handling to make the user enter a 5 letter or more word. If they do not re-prompt the user till they enter a word with the correct number of letters.</li> <li>Second prompt the user for a character(s) to replace.</li> <li>Third prompt the user for a character to replace with.</li> <li>If the character(s) are found replace the characters and output the new word. If the characters are not found, output "Characters not found".</li> </ul> | |
| 33 | Python | Strings | High | String Menu Option | NOTE: Do not use lists / arrays to solve this. Just use String methods, loops, and conditionals. <br> <br> Create a program that has a menu option that solves simple String programs. The menu option input must be an integer and if the user does not enter one of the following options re-prompt the user till they enter one of the following menu options. <br> <ul> <li><b>Option 1:</b> Write a program that prompts a user for a single word String and removes characters that have odd index values. Output the new word.</li> <li><b>Option 2:</b> Write a program that prompts a user for a single word String and reverses the String.</li> <li><b>Option 3:</b> Write a program that prompts a user for a single word String. Convert the given string to all uppercase if it contains at least 2 uppercase characters in the first 4 characters, otherwise output the original word.</li> <li><b>Option 4:</b> Write a program that prompts a user for a single word String. Sort the string alphabetically (A - Z) based upon the characters in the String.</li> <li><b>Option 5:</b> Write a program that prompts a user for at least an even number of words Swap every other words order. For example "the sunflowers swayed gently" would output as "sunflowers the gently swayed". Re-prompt the user till they enter an even number of words.</li> </ul> | |
| 34 | Python | Lists | Low | Find the Average | Create a program that takes user input of five numbers and determine the average. <br> <ul> <li>Organize the numbers from smallest to largest.</li> <li>Ignore the smallest and largest number when determining the average.</li> <li>Output the list created.</li> <li>Output the average (truncate / round down) to the nearest whole number.</li> </ul> | |
| 35 | Python | Lists | Low | Find Words Longer Than | Write a Python program to find the list of words that are longer than a given length from a given list of words. <br> <ul> <li>Prompt the user for a list of five words.</li> <li>Prompt the user for a given length to find.</li> <li>Output the original list.</li> <li>Output the words that are equal to or greater than a given length.</li> <li>If no words are greater than or equal to the length inputted, output: "No matches found"</li> </ul> <br> <b>NOTE:</b> The output of the list (see example output) is not simply outputting the list itself. Think Strings and concatenation. | |
| 36 | Python | Lists | Medium | Same Characters | Create a program that takes five user inputs and puts them into a list to count the number of strings that match the following criteria: <br> <ul> <li>The string length has to be 3 or more to be considered in the count.</li> <li>The first and last characters are the same to be considered in the count.</li> <li>Output the list created.</li> <li>Output the final count.</li> </ul> <br> <b>NOTE:</b> The output of the list (see example output) is not simply outputting the list itself. Think Strings and concatenation. | |
| 37 | Python | Lists | High | Comparing Lists | Create a program that prompts the user for two lists of five words each and compare the lists for similarities and differences between the two lists. <br> <ul> <li>Output the two lists.</li> <li>Output the similarities.</li> <li>Output the differences in the order they were entered.</li> </ul> <br> <b>NOTE:</b> The output this time of the list is just printing the list. | |
| 42 | Java | Output | Low | Practice Poem | Look up a poem (at least 6 lines long) and print out the poem in quotation marks and indent / tab every other line. <br> | |
| 38 | Python | Lists | High | One Letter Change Up | Write a program to prompt the user for a short word, three to five letters. Read from a dictionary (see Python - Sample Code and see how many words you can find by changing one letter at a time). <br> <ul> <li>Output the words as you find them, but DO NOT include the word to be found.</li> <li>Output the total words found.</li> <li>Ignore case sensitivity (i.e. "H" and "h" should be treated as the same character).</li> </ul> <br> <b>Reading From a File</b> <br> <code> # creating variable to store the <br> # number of words <br> number_of_words = 0 <br> <br> # Opening our text file in read only <br> # mode using the open() function <br> with open(r'SampleFile.txt','r') as file: <br> <br> # Reading the content of the file <br> # using the read() function and storing <br> # them in a new variable <br> data = file.read() <br> <br> # Splitting the data into separate lines <br> # using the split() function <br> lines = data.split() <br> <br> # Printing total number of words <br> print(lines) </code> | |
| 40 | Python | Procedures | Medium | Fix Me | Write a function called that returns an array that contains exactly the same numbers as the passed array, but rearranged so that every 9 is immediately followed by a 5. Do not move the 9's, but every other number may move. The array contains the same number of 9's and 5's, every 9 has a number after it that is not a 9, and a 9 appears in the array before any 5. <br> <br> <ul> <li>Create a function called: <b>fixMe</b></li> <li>The fixMe function has a parameter of the original array.</li> <li>The fixMe function returns the corrected array.</li> <li>When a 5 is moved adjust the numbers to the right.</li> <li>To test your code you will just pass the original array and print out the returned array.</li> </ul> | |
| 41 | Python | Procedures | Medium | Only These Characters | Write a function that returns true if all elements in an array are one of two numbers specified by the user. <br> <br> <ul> <li>Prompt the user for an array of 5 numbers.</li> <li>Prompt the user for two numbers to look for in the array.</li> <li>Write a function called only that has the following parameters: the array, first number to find, second number to find.</li> <li>Return True If every element in the array is one of these numbers, else return False.</li> <li>Output the value returned.</li> </ul> | |
| 39 | Python | Procedures | Medium | Mirror Me | For this program a "mirror" in an array is a group of contiguous elements such that somewhere in the array, the same group appears in reverse order. For example, the largest mirror section in {1, 2, 3, 8, 9, 3, 2, 1} is length 3 (the {1, 2, 3} part). <br> <ul> <li>Create a function called: <b>mirrorMe</b></li> <li>The mirrorMe function has a parameter, which is an array.</li> <li>Return an integer of the size of the largest mirror section found in the given array. </li> <li>Print out the integer value returned.</li> </ul> | |
| 44 | Java | Output | Low | Bingo Rules | Create a BingoRules application that displays the rules for playing bingo. Place each rule on a separate line and place a blank line between rules. First line will say Bingo Rules tabbed in, followed by 5 rules of bingo double spaced. <br> | |
| 43 | Java | Output | Low | Bingo Card | Create a BingoCard application that displays a traditional bingo card with five columns of five unique numbers. <br> <br> <b>NOTE: </b>For the Bingo Card you need to use the Format Method. <br> <ul> <li>The column labels are B, I, N, G, and O.</li> <li>Column B contains numbers ranging from 1 through 15</li> <li>Column I has numbers ranging from 16 through 30</li> <li>Column N has four numbers ranging from 31 through 45 and a Free Space in the middle of the column</li> <li>Column G has numbers ranging from 46 through 60</li> <li>Column O has numbers ranging from 61 through 75</li> </ul> <br> <h6>Format() Method</h6> The format() method can be used in place of the print() or println() methods to control the way output is displayed. The format() method arguments include a format string and an argument list. The format string contains specifiers that indicate how the corresponding strings in the argument list should be displayed. The following code demonstrates the format() method: <br> <br> <code> System.out.format("%-10s %8s %8s", "Team", "Wins", "Losses\n"); <br> System.out.format("%-10s %8s %8s", "Jaguars", "10", "5\n"); <br> System.out.format("%-10s %8s %8s", "Cheetahs", "14", "1\n"); <br> System.out.format("%-10s %8s %8s", "Panthers", "8", "7\n"); <br> System.out.format("%-10s %8s %8s", "Penguins", "4", "11\n"); <br> </code> <br> | |
| 45 | Java | Output | Low | Shapes | Create a Shape application that displays two shapes of asterisks (*). The two shapes should be at least 15 asterisks wide and 7 asterisks high using at <b>least</b> 2 escape sequences. | |
| 46 | Java | Output | Low | Smile | Create a Smile application that displays a smiling face made of keyboard characters. | |
| 47 | Java | Output | Low | Your Initials | Write a Java program to display your initials for your first name, middle name, and last name (ex. CEB). Use the letters in your initials to form each letter of your initials, for example see how JAVA is spelled in the following pattern with 'J' for the letter J, 'a' for the letter a, and etc. | |
| 48 | Java | Variables | Low | Variable Reassignment & Arithmetic (Math) | Create a Java program to apply variable reassignment and arithmetic operators. <br> <ul> <li>Choose the correct data type: int, double</li> <li>Create a variable name (your choice): int myNumber;</li> <li>Use variable reassignment and/or arithmetic operators: myNumber = myNumber + 1;</li> <li>Use print statements to output the value of the variable: System.out.println(myNumber);</li> </ul> What is the value of each of the following expressions: <br> <ul> <li>Create and initialize a variable with the value of 5 and print out that value.</li> <li>Change the variable value above to 10 and print out the new value.</li> <li>Create and initialize a variable with the value of 6.4567 and print out that value.</li> <li>Change the variable value above to 9.12345 and print out the new value.</li> <li>Create a variable and solve 5 + 7 - 3 and print out the value.</li> <li>Create a variable and solve 10 * 2 - 3 and print out the value.</li> <li>Create a variable and solve 10 * (2 - 3) and print out the value.</li> <li>Create a variable and solve 8 - 3 * 2 and print out the value.</li> </ul> | |
| 49 | Java | Variables | Low | Object Height | The height of an object at any given time dropped from a starting height of 100 meters is given by the equation: <br> <br> <code> h = 100 – 4.9 * t * t <br> </code> <b>NOTE: </b> 't' is the time in seconds <br> <br> Create an ObjectHeight application that prompts the user for a time less than 4.5 seconds and then displays the height of the object at that time. The application output should look like: | |
| 50 | Java | Variables | Low | Pizza Cost | The cost of making one pizza at a local shop is as follows: <br> <ul> <li>Labor cost is $1.25 per pizza, regardless of size </li> <li>Rent cost is $1.50 per pizza, regardless of size </li> <li>Material cost is $0.10 x size x size </li> <li>The state tax rate is 6% </li> </ul> Create a PizzaCost application that prompts the user for the size of a pizza and then displays the cost of making the pizza before and after taxes. <br> <ul> <li>Labor, rent, taxes, and material costs must be assigned to variables.</li> </ul> <b>NOTE: </b>Use NumberFormat.getCurrencyInstance to format the output for the cost. | |
| 51 | Java | Variables | Medium | Steps Per Day | Write a program that: <br> <ul> <li>Prompts the user for the number of steps they walk for four days in a row. </li> <li>Next have the program calculate the total number of steps, the average number of the steps, and convert the steps to miles as well. </li> </ul> <br> <b>NOTE: </b>Use the Scanner class method of nextInt() to obtain a value from the user. <br> <br> <b>NOTE: </b>Use NumberFormat.getIntegerInstance to format the output for the steps output. <br> <br> <b>NOTE: </b>Getting the wrong answer? Check your formula for order of operations. <br> <br> For this program, let's say 2,000 steps are in a mile. | |
| 52 | Java | Variables | Medium | Days | Create a Days application that prompts the user for a number of Days. Next have the computer compute and print out the following: <br> <br> <b>NOTE: </b>Use the Scanner class method of nextInt() to obtain a value from the user. <br> <br> <b>NOTE: </b>Use NumberFormat.getIntegerInstance to format the output for hours, minutes, and seconds. S <ul> <li>number of weeks</li> <li>number of hours</li> <li>number of minutes</li> <li>number of seconds</li> </ul> | |
| 53 | Java | Variables | Low | Height | Create a Height application that prompts the user for a person's height in inches and coverts the input to feet and inches, for example: <br> <br> <b>NOTE: </b>Use the Scanner class method of nextInt() to obtain a value from the user. See page 81 in the textbook. <br> <br> <b>NOTE: </b>There are 12 inches in every foot. | |
| 56 | Java | Variables | Low | Simple Interest | There are two kinds of interest. Simple and compound. With simple interest, the amount of the deposit remains the same, and the amount of interest is paid at the end of a time interval. For example, if $1,000 is deposited for 7 years at an interest rate of 6% per year, $60 will be deposited at the end of each year. <br> <ul> <li>The value of the amount after the term is calculated using the formula:</li> </ul> <code> Amount = Principal * (1 + years * interest rate) <br> </code> <br> Create a SimpleInterest application that prompts the user for the principal, number of years, and interest rate. Then calculates the amount of interest. <br> <br> <b>NOTE: </b>The output should use the NumberFormat class for the Simple Interest amount outputted (i.e. $6,500 in the example below). | |
| 57 | Java | Variables | High | Election | Create an Election application that will prompt the user for the number of Votes for two candidates - Awbrey and Martinez. After prompting for the number of votes from each state, calculate the percentage of votes for both candidates and display the results. | |
| 58 | Java | Variables | Medium | Change | Create a Change application that prompts the user for an amount of change in cents and then displays the minimum number of coins necessary to make the change (i.e. start with determining how many quarters, then dimes, etc.). The change can be made of quarters, dimes, nickels, and pennies. <br> <br> <b>NOTE: </b>The amount of change is reduced each time you determine the number of quarters, then dimes, and then nickels. | |
| 59 | Java | Variables | Medium | Digits | Create a Digits application that will show the hundreds-place, tens-place, and ones-place. <br> <br> <b>HINT: </b>The way I solved this problem was using a mixture of integer division, subtraction at times, and mod division. I started first with the hundreds spot and division, then ten's spot with some subtraction and division, and then one's spot using modulus. | |
| 60 | Java | Variables | High | Time Conversion | Create a TimeConversion application that prompts the user for a time in minutes and then displays the time in hours and minutes. <br> <br> Be sure to consider times when the number of minutes left over is less than 10 (for example 184 minutes should produce 3:04 in the hour:minute format). To do this use the same formula / strategy you used to figure out the Digits. <br> <br> <b>NOTE: </b>I do not want to see anything fancy with conditionals or sub-string, etc. | |
| 61 | Java | Conditionals | Low | Printing | Printing prices are typically based on the number of copies to be printed. <br> <ul> <li>0 - 99 $0.30 per copy</li> <li>100 - 499 $0.28 per copy</li> <li>500 - 749 $0.27 per copy</li> <li>750 - 1000 $0.26 per copy</li> <li>over 1000 $0.25 per copy</li> </ul> Create a Printing application that prompts the user for the number of copies to print and then displays the price per copy and the total price for the job. <br> <br> <b>NOTE: </b>The output must be formatted using the currency / money format. | |
| 62 | Java | Conditionals | Medium | Package Check | Your shipping company is going international and you need to rewrite your company's software to use kilograms and cubic meters. <br> <br> Your international delivery service does not accept packages heavier than 27 kilograms or larger than 0.1 cubic meters (100,000 cubic centimeters). Create a PackageCheck application that prompts the user for the weight of a package and its dimensions in centimeters (length, width, and height), and then displays an appropriate message if the package does not meet the requirements. <br> <br> <code> length(cm) × width(cm) × height(cm) = cubic centimeters <br> </code> <br> To calculate the cubic meters: <ul> <li>length in cm / 100 = length in meters</li> <li>width in cm / 100 = width in meters</li> <li>height in cm / 100 = height in meters</li> <li>length in meters x width in meters x height in meters = cubic meters</li> </ul> Messages should include: <ul> <li>Ready to ship</li> <li>Too heavy</li> <li>Too large</li> <li>Too heavy and too large</li> </ul> | |
| 63 | Java | Conditionals | Medium | Eggs | A wholesale egg company bases their prices on the number of individual eggs purchased: <br> <ul> <li>0 up to but not including 4 dozen: $0.50 per dozen</li> <li>4 up to but not including 6 dozen: $0.45 per dozen</li> <li>6 up to but not including 11 dozen: $0.40 per dozen</li> <li>11 or more dozen: $0.35 per dozen</li> </ul> <b>NOTE: </b>Extra eggs are priced at 1/12 the per dozen price. <br> <b>NOTE: </b>The output must be formatted using the currency / money format. | |
| 64 | Java | Conditionals | Low | Car Recall (SWITCH Statements) | <b>NOTE: </b>You have to write the code using a SWITCH statement for this program. No IF statements. <br> <br> An auto company produced some models of cars that may be difficult to drive because the car wheels are not exactly round. Cars with model numbers 119, 179, 189 through 195, 221, and 780 have been found to have this defect. In addition only the model number of 179 also needs a new bumper. <br> <br> <ul> <li>Create a CarRecall application that prompts a customer for the model number of their car to find out if it is defective.</li> <li>Displays “Your car is not defective.” when the user typed a model number without a defect.</li> <li>Otherwise, the message “Your car is defective. It must be repaired.” should be displayed.</li> <li>Model number 179 also needs a special prompt to inform: "Your car is defective and needs a new bumper. It must be repaired."</li> </ul> | |
| 69 | Java | Conditionals | High | Decay | The formula used in the BacteriaGrowth problem can also be used in decay problems. In decay problems, k is negative. <br> <br> Create an application that allows the user to select from the following options: <ul> <li>Calculate the final amount: ne<sup>–kt</sup> <li>Calculate the initial amount: y / e<sup>–kt</sup></li> <li>Calculate the constant (called the half-life): (log (y/n)) / t</li> </ul> <b>NOTE: </b> 'e' represents Math.exp <br> <br> The application should prompt the user to select one of the three choices and based on the selected option prompts the user to enter the appropriate known information. <br> <br> For example, a radioactive mass of 200 grams will reduce to 100 grams in 10 years. Based on this information, the half-life is calculated to be –0.06931. <br> <br> Here are what the variables in the formulas below stand for: <ul> <li><b>y</b> is the final amount</li> <li><b>n</b> is the initial amount</li> <li><b>k</b> is a constant</li> <li><b>t</b> is the time</li> </ul> | |
| 68 | Java | Conditionals | High | Bacteria Growth | The formula y = ne<sup>kt</sup> can be used for estimating growth where: <br> <ul> <li>y is the final amount</li> <li>n is the initial amount</li> <li>k is a constant</li> <li>t is the time</li> </ul> <br> <b>HINT: </b>If you look at the formula above, you should notice that 'e' is not a variable. So look above at the Math methods in the Reading section and find out what it stands for in the formula. <br> <br> For example, this formula could be used for estimating population growth in a region or for estimating cell growth in a lab experiment. Create a BacteriaGrowth application that calculates how many bacteria will be present based on this formula. <ul> <li>The application should prompt the user initial bacteria, the constant k, and the time. </li> </ul> | |
| 65 | Java | Conditionals | High | Volume | The volume of objects are calculated differently depending on the shape of the object. <br> <ul> <li>Begin your program by entering a number for the shape to calculate (1 - Rectangular Prism, 2 - Sphere, or 3 - cube).</li> <li>Based upon the shape chosen prompt display the choice and prompt the user for the information needed to calculate that shapes volume.</li> </ul> <h6>Rectangular Prism</h6> The volume of a rectangular prism is calculated using the formula: <br> <code> V = lwh <br> </code> <br> <h6>Sphere</h6> The volume of a sphere is calculated using the formula: <br> <code> πd<sup>3</sup> / 6 <br> </code> <br> <b>NOTE: </b>Use the Math,PI and Math.pow methods. <br> <b>NOTE: </b>The formula being used, uses the diameter. <br> <br> <h6>Cube</h6> The volume of a cube is calculated using the formula: <br> <code> V = s<sup>3</sup> <br> </code> <br> Prompt the user for the length of each side of a cube. The application should then display the volume of the cube. | |
| 66 | Java | Conditionals | Low | MyPow | The MyPow application should prompt the user for two numbers and then display the result from the formula and, for comparison, show the same result using the Math pow() method. <br> <ol> <li>Create a MyPow application that uses the formula: e(Y * log(X)) to calculate XY.</li> <li>Use the same numbers inputted and use the Math.pow() method and display the output.</li> </ol> <b>NOTE: </b>e is short for exponent <em>(exp(double num))</em> and log is logarithms <em>(log(double num))</em> (see above readings for more information on how to apply these Math methods. | |
| 67 | Java | Conditionals | Medium | Car Payment | Create a CarPayment application that calculates a monthly car payment after prompting the user for the principal owing (P), the interest rate (r) and the number of monthly payments (m). The monthly car payment is calculated using the formula: <br> <br> <code> P(r /12) / (1-(1+r/12)<sup>-m</sup>) <br> </code> <br> <b>NOTE: </b>In the formula above that is a negative sign in front of the m, which makes it -m. <br> <b>HINT: </b>To solve don't forget about order of operations and the Math methods that you can use. <br> <b>NOTE: </b>The output should be formatted using the money / currency format. | |
| 70 | Java | Iteration | Medium | Prime Number | A prime number is an integer greater than 1 that is evenly divisible by only 1 and itself. For example 2, 3, 5, and 7 are prime numbers, but 4, 6 , 8, and 9 are not. The secret is modulus!!! <br> <ul> <li>The only even prime number is 2. All other even numbers can be divided by 2 and are not prime numbers. For example 4 MOD 2 equals 0, which is your hint how you can use modulus to determine if a number is even or odd.</li> <li>If the sum of a number's digits is a multiple of 3, that number can be divided by 3 and is not a prime number. This means that not all odd numbers are automatically prime numbers. Your hint once again is modulus. For example 9 MOD 3 equals 0, which means it divides evenly by three and is not a prime number.</li> <li>Any number divisible by 5 and does not have a remainder is not a prime number (HINT: It is the same hint as above).</li> <li>Any number divisible by 7 and does not have a remainder is not a prime number (HINT: It is the same hint as above).</li> <li>Any number divisible by 11 and does not have a remainder is not a prime number (HINT: It is the same hint as above).</li> <li>Any number divisible by 13 and does not have a remainder is not a prime number (HINT: It is the same hint as above).</li> </ul> Here is a list of prime number from 2 to 97 to help you check your work: <br> <br> <code> 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 <br> </code> <br> Create a PrimeNumber application that has two modes: <ul> <li>Prompts the user for a number and the displays a message indicating whether the number is prime or not. Write out "Prime" or "Not Prime" to pass the tests.</li> <li>Prompts the user for two numbers and then displays the prime numbers between those numbers (HINT: This is where you will need to use a loop).</li> </ul> | |
| 71 | Java | Iteration | Low | Investment | Create an Investment application that calculates how many years it will take for an <em>initial</em> investment to be worth at least <em>x</em> amount of money if compounded annually at 7.5%. <br> <ul> <li>Prompt the user for the initial investment.</li> <li>Prompt the user for the amount of money you want to earn.</li> <li>Every iteration / loop is equal to 1 year</li> <li>Output the dollar amount of the investment as it grows each year</li> <li>Output how many years (loops) it took to reach the amount you wanted to earn</li> </ul> | |
| 72 | Java | Iteration | Low | Digit Sum | Create a DigitsSum application that prompts the user for a non-negative integer and then displays the sum of the digits. <br> <br> <ul> <li>This program builds upon the DigitsDisplay and Digits program, but the output is the sum of the number entered (ex. 8 + 9 + 2 = 19).</li> <li>You need to catch in your program if a user enters a value that is not a non-negative integer. If they do enter an incorrect value you need to prompt them of this and have them re-enter their value.</li> </ul> | |
| 73 | Java | Iteration | High | Random Walk | In the “random walk” problem, a person is placed at the center of a 7 meter long bridge. Each step the person moves 1 meter either forward or backward at random. <br> <table border="1" style="width:100%"> <tr> <td></td> <td></td> <td></td> <td> X </td> <td></td> <td></td> <td></td> </tr> </table> <br> Create a RandomWalk application that determines how many steps the person will walk before taking a step off the bridge. <br> <ul> <li>Have the application run 50 trials</li> <li>At the end of the 50th run display the average</li> <li>At the end of the 50th run display the maximum number of steps</li> </ul> <br> <b>Hint:</b> Generate a random number between 0 and 1, with 0 meaning to go forward and 1 meaning to go backward. <br> <b>NOTE:</b> My average steps ranged between 15 to 20. What does it mean if you have some very large average number of steps? What did you not account for in your code? | |
| 74 | Java | Strings | Low | CharAt | Write a program where the user enters a string, and the program echo's it to the monitor with one character per line: <br> <br> <ul> <li>To do this you will need to use the following method from class String: char charAt( int index )</li> <li>This method returns the character that is at index inx of the String. Characters are indexed beginning at index 0.</li> </ul> | |
| 75 | Java | Strings | Medium | Name Echo | Write a program that asks for user's first and last name in one input and then writes it back with the first name as entered, and the second name all in capital letters. Assume that there are two names, and that they are separated by a single space character. Use the trim() method to remove possible leading spaces. <br> <br> The following String methods will help you complete this exercise: <ul> <li>trim()</li> <li>int indexOf( String <Your String Variable Name>)</li> <li>String substring( int startindex ) </li> <li>String substring(int start, int end)</li> <li>String concat( String str ) — or use the + operator</li> <li>String toUpperCase()</li> </ul> Last part is to test if there were indeed more than one name entered. (Test that the value returned from indexOf() is greater than zero.) If not, merely echo the input. <br> <br> <b>NOTE:</b> This is part of error handling, because if you don't several of your string methods will trigger StringIndexOutOfBoundsException errors. | |
| 76 | Java | Procedures | Low | House | Create a House application that calls methods: <br> <ul> <li>addRoof()</li> <li>addBase()</li> <li>addWalk()</li> </ul> These three methods when combined should display a House similar to the one below: | |
| 77 | Java | Procedures | Low | Is Prime | Modify the <b>Prime Number</b> application created in the conditional exercises to include: <br> <ul> <li>A method named isPrime().</li> <li>The isPrime() method should require one parameter and return a Boolean value.</li> <li>The main method would print whether a number is prime or not prime based upon the Boolean value returned.</li> </ul> |