These projects were created by Leigh Anne Fitz and Lisa Ferran to support student learning in AP Computer Science A. They are intended to promote curiosity, creativity, collaboration, and confidence as students begin their journey into computer science.
We hope these projects make learning Java both challenging and enjoyable, and that they provide a strong foundation for the exciting topics that follow throughout the AP Computer Science A course.
Learning to program is much like learning a new languageβyou develop fluency by reading, writing, practicing, and creating. These projects are designed to help you move beyond simply memorizing Java syntax and instead develop the problem-solving and computational thinking skills that are essential to becoming a successful programmer.
Remember that mistakes are a natural part of programming. Every error message, failed test, and debugging session is an opportunity to deepen your understanding. Success in computer science comes not from writing perfect code the first time, but from learning how to analyze problems, experiment with solutions, and improve your work through persistence.
Each project is designed to reinforce these concepts through engaging, authentic programming experiences. Rather than completing isolated coding exercises, you will apply your knowledge to solve meaningful problems, debug code, and create programs that demonstrate your understanding. As the projects progress, youβll be encouraged to think critically, test your ideas, and refine your solutionsβjust as professional software developers do.
First, you must create a Scanner object and direct it to look for input from the user (System.in). This is done by writing the following line of code in your main method:
You can use these methods to read input from the user and store it in variables for later use in your program. For example, to read an integer from the user and store it in a variable called age, you would write:
You will need to have a .next method for each input you want to read from the user. For example, if you want to read three integers from the user, you will need to have three separate .nextInt() methods.
At the end of each program that you use the Scanner class, it is good practice to close the Scanner object to free up system resources. This is done by writing the following line of code at the end of your main method:
The format method takes two arguments: a format string and the values to be formatted. This will format the double value to two decimal places and return a string representation of the value:
This project will give you practice using the Scanner class to read user input, performing calculations with variables, and formatting output. You will write a program that calculates the total value of coins in a jar based on user input for the number of quarters, dimes, nickels, and pennies.
In the main method, you should allow the user to input the number of coins in a jar. You should have separate inputs for quarters, dimes, nickels, and pennies. Be sure to write an appropriate prompt before each input so that the user knows what value they should be entering. The program should then display the values that represent the amount of each type of coin entered and then display the total value of all of the coins. Be sure the output is pleasing to the eye, and be sure all money totals are properly formatted to two decimal places and include a dollar sign.
The total amount in the jar is $4.39
The breakdown is as follows:
There are 15 quarters worth $3.75
There are 5 dimes worth $0.50
There are 2 nickels worth $0.10
There are 4 pennies worth $0.04
This project will give you practice using the Scanner class to read user input, performing calculations with variables, and formatting output. You will write a program that calculates the number of containers needed to ship a given number of dooflingies, using the fewest containers possible.
The shipping clerk at the Rinky Dooflingy Company is faced with the following problem: Dooflingies are very delicate and must be shipped in special containers. These containers are available in four sizes: huge, large, medium, and small, which can hold 50, 20, 5, and 1 dooflingy, respectively. Your program should allow a user to input any total number of dooflingies to be shipped and then display the number of huge, large, medium, and small containers needed to send the shipment in the minimum number of containers, and with the minimum amount of wasted space.