Java exercises
Write a command line program that will print out the lyrics to 99 Bottles.
Begin ExerciseWrite a program that creates a two-dimensional array initialized with test data. Use any primitive data type you wish.
Begin ExerciseWrite an application that asks the user to enter a 10-character telephone number and translates alphabetic characters to numeric equivalent
Begin ExerciseWrite a class that has three overloaded static methods for calculating the areas for circles, rectangles and cylinders with the provided formulas.
Begin ExerciseWrite a program that uses nested loops to collect data and calculate the average rainfall over a period of years.
Begin ExerciseWrite a program that asks for the number of checks written for the month. The program should then calculate and display the bank's services fees for the month.
Begin ExerciseWrite a program that asks the user to enter the number of books that he or she has purchased this month and displays the number of points awarded.
Begin ExerciseWrite a program that asks the user to enter the amount that he or she has budgeted for a month. A loop should then prompt the user to enter each of his or her expenses for the month, and keep a running total.
Begin ExerciseFor this exercise, you will design a set of classes that work together to simulate a car's fuel gauge and odometer. The classes you will design are a FuelGauge and Odometer.
Begin ExerciseThe westfield carpet company has asked you to write an application that calculates the price of carpeting for rectangular rooms. To calculate the price, you multiply the area of the floor(width times length) by the price per square foot of carpet.
Begin ExerciseWrite a program that displays temps up to 100 degrees fahrenheit.
Begin ExerciseWrite a program that asks the user to enter a string and then asks the user to enter a character.
Begin ExerciseWrite a program that demonstrates the Circle class by asking the user for the circle's radius, creating a Circle object, and then reporting the circle's area, diameter, and circumference.
Begin ExerciseWrite a program that asks the user for the retail price of a circuit board calculates the amount of profit earned for that product, and displays...
Begin ExerciseWrite a program that demonstrates the Coin class. The program should create an instance of the class and display the side that is initially facing up. Then, use a loop to toss the coin 20 times.
Begin ExerciseWrite a program that generate all combinations of a set returning only that satisfy a size of n.
Begin ExerciseThe numbers in the deposits.txt file are the amounts of deposits that were made to a savings account during the month, and the numbers
Begin ExerciseWrite a program that plays a simple dice game between the computer and the user.
Begin ExerciseWrite a program that test your esp (extrasensory perception). The program should randomly select the name of a color...
Begin ExerciseA soft drink company recently surveyed 12,467 of its customers and found that approximately 14 percent of those surveyed purchase one or more energy
Begin ExerciseWrite a program with a method named isEven that accepts an int argument. The method should return true if the argument is even, or false if otherwise.
Begin ExerciseWrite a program that asks the user to enter the number of calories and fat grams in a food item.
Begin ExerciseFor this assignment, you will write a program that simulates a fishing game. In this game, a six-sided die is rolled to determine what the user has caught
Begin ExerciseWrite a program that demonstrate the class. The program should ask the user to enter a temperature, and then display a list of the substance that will freeze at that temperature and those that will boil at that temperature.
Begin ExerciseFor this assignment, you will write a program that lets the user play against the computer in a variation of the popular blackjack card game.
Begin ExerciseDesign a Geometry class that calculates the area of a circle, triangle and a rectangle. Display an error message if user enters a number outside of range.
Begin ExerciseWrite a program that generates a random number and asks the user to guess what the number is.
Begin ExerciseWrite a method named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise.
Begin ExerciseWrite a program that calculates the number of acres in a tract of land with 389,767 square feet.
Begin ExerciseWrite a program that asks the user to enter a month (in numeric form), a day, and a two-digit year. The program should then determine whether the day times the month is equal to the year; if so, it should display a message indicating that the date is magic.
Begin ExerciseWrite a program that asks the user to enter an object’s mass, and then calculate its weight. If the object weighs more than 1000 Newtons, display a message indicating that it is too heavy.
Begin ExerciseWrite a program that asks the user to input the number of miles driven and gas used.
Begin ExerciseWrite a program with a class that contains methods wordCount, mostFrequent, and replaceSubstring string operations
Begin ExerciseWrite a program that asks the user to enter a string, and then converts that string to Morse code. Use hyphens for dashes and periods for dots.
Begin ExerciseWrite a program that computes loan payments. The loan can be a car loan, a student loan, or a home mortgage loan.
Begin ExerciseWrite a program that reads the contents of the two files into two separate arrays, or ArrayLists. The user should be able to enter a boy’s name, or a girl’s name, or both.
Begin ExerciseWrite program that accepts users input and validates if the input is a palindrome.
Begin ExerciseFor this assignment you will design a set of classes that work together to simulate a police officer issuing a parking ticket. You should design ParkedCar, ParkingMeter, PoliceOfficer and ParkingTicket class.
Begin ExerciseWrite a program to validate passwords based on length, if it contains an upper/lower case char and contains a digit
Begin ExerciseWrite a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day...
Begin ExerciseWrite a class named PhoneBookEntry that has fields for a person’s name and phone number. The class should have a constructor and appropriate accessor and mutator methods.
Begin ExerciseWrite a program that reads a sentence as input and converts each word to Pig latin.
Begin ExerciseWrite a program that has a function named presentValue that performs this calculation.
Begin ExerciseWrite a RainFall class that stores the total rainfall for each of 12 months into an array of doubles.
Begin ExerciseWrite a program that lets the user play the game of Rock, Paper, Scissors against the computer.
Begin ExerciseWrite a program that prompts the user to enter a number within the range of 1 through 10. The program should display the Roman numeral version of that number.
Begin ExerciseWrite a program that asks for the names of runners and the time it took each of them to finish a race.
Begin ExerciseWrite a program that opens a file and processes daily sales numbers. The program should provide weekly and overall summary statistics
Begin ExerciseDesign a SavingsAccount class that stores a savings account’s annual interest rate and balance. The class constructorshould accept the amount of the savings account’s starting balance.
Begin ExerciseWrite a program that asks the user to enter three names, and then display the name sorted in ascending order.
Begin ExerciseWrite a program that displays a menu allowing the user to select air, water, or steel.
Begin ExerciseWrite a program that asks the user for a positive integer no greater than 15. The program should then draw a square on an output file using the character ‘X’.
Begin ExerciseKathryn bought 600 shares of stock at a price of $21.77 per share. She must pay her stockbroker a 2 percent commission for the transaction.
Begin ExerciseWrite a program that asks the user to enter the name of his or her favorite city. Use a String variable to store the input
Begin ExerciseWrite a program that asks the user to enter a series of single digit numbers and calculate the sum of all the numbers
Begin ExerciseWrite a program that asks the user to enter in test scores and then displays the average score.
Begin ExerciseDesign a TestScores class that has fields to hold three test scores. The class should have a constructor, accessor and mutator methods for the test score fields, and a method that returns the average of the test scores.
Begin ExerciseFor this assignment you will create a game program using the coin class from the coin toss simulator exercise. The program should have three three instances of the coin class: one representing a quarter, one representing a dime, and one representing a nickel
Begin ExerciseThe program should create an array of 10 Question objects, one for each trivia question. Make up your own trivia questions on the subject or subject of your choice for the objects.
Begin ExerciseWrite a program that asks the user for the names of two files. The first file should be opened for reading and the second file should be opened for writing.
Begin ExerciseWrite a method that accepts String objects as an argument and returns the number of words.
Begin ExerciseWrite a program that accepts as input a sentence in which all of the words are run together but the first character of each word is uppercase.
Begin ExerciseWrite a program that lets the user enter the name of a team and then displays the number of times that team has won the world series in the time period from 1903 through 2009.
Begin ExerciseWrite a program that solves the following equation using Cramer’s rule and displays the value for x and y
Begin ExerciseWrite a program that displays the area and perimeter of a circle.
Begin ExerciseWrite a program that displays the area and perimeter of a rectangle.
Begin ExerciseWrite a program that prompts the user to enter the side of a hexagon and displays its area.
Begin ExerciseWrite a program that prompts the user to enter the length from the center of a pentagon to a vertex and computes the area of the pentagon.
Begin ExerciseWrite a main method that prompts the user to enter the number of sides and the side of a regular polygon and displays its area.
Begin ExerciseWrite a main method that prompts the user to enter the number of sides and the side of a regular polygon and displays its area
Begin ExerciseWrite a program that reads student scores, gets the best score, and then assigns grades based
Begin ExerciseWrite two overloaded methods that return the average of an array.
Begin ExerciseWrite a program that displays the average speed in kilometers per hour.
Begin ExerciseWrite a program that displays the average speed in miles per hour
Begin ExerciseWrite a sort method that uses the bubble sort algorithm. The bubble sort algorithm makes several passes through the array
Begin ExerciseWrite a program that reads in investment amount, annual interest rate, and number of years, and displays the future investment value.
Begin ExerciseWrite a program that reads the balance and the annual percentage interest rate and displays the interest for the next month.
Begin ExerciseWrite the following method that returns true if the list is already sorted.
Begin ExerciseWrite a program that lets the user enter the loan amount and loan period in number of years.
Begin ExerciseWrite a program that prompts the user to enter a monthly saving amount and displays the account value after the sixth month.
Begin ExerciseWrite a program that prompts the user to enter an amount and calculates a CD value
Begin ExerciseComputes the standard deviation of numbers by creating two methods deviation and mean.
Begin ExerciseWrite a program that displays the result of two random expressions
Begin ExerciseWrite a program that computes the tuition in ten years and the total cost of four years’ worth of tuition starting ten years from now.
Begin ExerciseFind the greatest common divisor of two integers n1 and n2.
Begin ExerciseWrite a program that reads three edges for a triangle and computes the perimeter if the input is valid.
Begin ExerciseWrite a program that reads in the radius and length of a cylinder and computes the area and volume
Begin ExerciseWrite a program that displays conversion from kilograms to pounds in a table.
Begin ExerciseWrite a program that displays conversion from miles to kilometers in a table.
Begin ExerciseWrite a program that reads a Celsius degree in a double value from the console, then converts it to Fahrenheit and displays the result.
Begin ExerciseWrite a program that reads a number in feet, converts it to meters, and displays the result.
Begin ExerciseWrite a program that prompts the user to enter a letter grade A, B, C, D, or F and displays its corresponding numeric value 4, 3, 2, 1, or 0.
Begin ExerciseWrite a program that reads the integers between 1 and 100 and counts the occurrences of each. Assume the input ends with 0.
Begin ExerciseWrite a program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values (not counting zeros).
Begin ExerciseWrite a program that generates 100 random integers between 0 and 9 and displays the count for each number.
Begin ExerciseWrite a program that prompts the user to enter a string and displays the number of the uppercase letters in the string.
Begin ExerciseWrite a program that prompts the user to enter a string and displays the number of vowels and consonants in the string.
Begin ExerciseWrite a program to simulate the number of picks needed to get four cards from each suit and display the four cards picked.
Begin ExerciseWrite a program that prompts the user to enter a decimal integer and displays its corresponding binary value.
Begin ExerciseWrite a program that prompts the user to enter an integer between 0 and 15 and displays its corresponding hex number.
Begin ExerciseWrite a program that prompts the user to enter a decimal integer and displays its corresponding octal value.
Begin ExerciseWrite a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid
Begin ExerciseWrite a method with the following header to display an integer in reverse order
Begin ExerciseWrite a program that prompts the user to enter the year and first day of the year and displays the calendar table for the year on the console.
Begin ExerciseWrite a program that displays all the leap years, ten per line, in the twenty-first century
Begin ExerciseWrite a test program that prompts the user to enter n and displays an n-by-n matrix
Begin ExerciseWrite a nested for loop that prints numbers in a pyramid pattern.
Begin ExerciseDisplay all the prime numbers between 2 and 1,000, inclusive
Begin ExerciseWrite a program that randomly generates an integer between 1 and 12 and displays the English month
Begin ExerciseWrite a program that prints the characters in the ASCII character table from ! to ~.
Begin ExerciseWrite a program that prompts the user to enter the year and first day of the year, and displays the first day of each month in the year on the console.
Begin ExerciseWrite a program that displays to the console that contains three strings.
Begin ExerciseWrite a test program that reads in ten integers, invokes the method that will eliminate duplicate values, and displays the result.
Begin ExerciseWrite a program that randomly generates an array of 100,000 integers and a key to search and sort
Begin ExerciseWrite a program that reads the subtotal and the gratuity rate, then computes the gratuity and total.
Begin ExerciseWrite a program prompt the user to enter the weight and price of the each package and displays the one with the better price
Begin ExerciseWrite a program that prompts the user to enter the exchange rate from currency in U.S. dollars to Chinese RMB.
Begin ExerciseWrite a program that prompts the user to enter an integer for today’s day of the week and a future day of the week.
Begin ExerciseWrite a program that displays all the numbers from 100 to 1,000, ten per line, that are divisible by 5 and 6.
Begin ExerciseWrite a program that receives an ASCII code (an integer between 0 and 127) and displays its character.
Begin ExerciseWrite a program that reads an integer and displays all its smallest factors in increasing order.
Begin ExerciseWrite a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the name of the student with the highest score.
Begin ExerciseWrite a method that returns the index of the smallest element in an array of integers.
Begin ExerciseWrite a program that prompts the user to enter the month and year and displays the number of days in the month.
Begin ExerciseWrite a program that prompts the user to enter the minutes and displays the number of years and days for the minutes.
Begin ExerciseWrite a program that finds out the minimum number of sales you have to generate in order to make $30,000.
Begin ExerciseWrite a method that finds the smallest element in an array of double values
Begin ExerciseWrite a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score and the student with the second-highest score.
Begin ExerciseWrite a test program that prompts the user to enter a number and its width and displays a string returned by invoking format
Begin ExerciseWrite a program to generate three single-digit integers and prompt the user to enter the sum of these three integers.
Begin ExerciseWrite a program to play a variation of the game of the popular craps dice game!
Begin ExerciseGenerate a lottery of a three digit numbers. The program prompts the user to enter a three-digit number and determines whether the user wins.
Begin ExerciseWrite a program to print 100 uppercase letters and then 100 single digits, printing ten per line.
Begin ExerciseAssume a vehicle plate number consists of three uppercase letters followed by four digits. Write a program to generate a plate number.
Begin ExerciseWrite a program that prompts the user to enter four points and displays the intersecting point.
Begin ExerciseWrite a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle.
Begin ExerciseWrite a program that prompts the user to enter a point (x, y) and checks whether the point is within the circle
Begin ExerciseWrite a program that prompts the user to enter the three points for p0, p1, and p2 and displays whether p2 is on the left of the line from p0 to p1, to the right, or on the same line.
Begin ExerciseWrite a program that prompts the user to enter a point with x and y-coordinates and determines whether the point is inside the triangle.
Begin ExerciseWrite a program that prompts the user to enter the center coordinates and radii of two circles and determines whether the second circle is inside the first or overlaps with the first.
Begin ExerciseWrite a program that prompts the user to enter the center x-, y-coordinates, width, and height of two rectangles and determines whether the second rectangle is inside the first or overlaps with the first.
Begin ExerciseWrite a program that lets the user guess whether the flip of a coin results in heads or tails.
Begin ExerciseThe monthly payment for a given loan pays the principal and the interest.
Begin ExerciseWrite a program to display all open locker numbers separated by exactly one space
Begin ExerciseWrite a program that displays all possible combinations for picking two numbers from integers 1 to 7. Also display the total number of all combinations.
Begin ExerciseWrite a program that prompts the user to enter 10 integers and displays all combinations of picking two numbers from 10.
Begin ExerciseWrite a program that reads integers, finds the largest of them, and counts its occurrences.
Begin ExerciseWrite a method that finds the number of occurrences of a specified character in a string
Begin ExerciseWrite a program that prompts the user to enter three cities and displays them in ascending order
Begin ExerciseWrite a test program that prompts the user to enter an integer and reports whether the integer is a palindrome.
Begin ExerciseWrite a program that will display four perfect numbers less than 10,000.
Begin ExerciseWrite a program that prompts the user to enter the starting velocity v0 in meters/second, the ending velocity v1 in meters/second, and the time span t in seconds, and displays the average acceleration.
Begin ExerciseWrite a program that prompts the user to enter v in meters/second (m/s) and the acceleration a in meters/second squared (m/s2), and displays the minimum runway length.
Begin ExerciseWrite a program that picks four cards from a deck of 52 cards and computes their sum.
Begin ExerciseWrite a program that prompts the user to enter the three points for p0, p1, and p2 and displays whether p2 is on the line segment from p0 to p1.
Begin ExerciseWrite a program to display the population for each of the next five years.
Begin ExerciseWrite a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exactly one space.
Begin ExerciseWrite a program that displays in a table format a number, square and the power of 3.
Begin ExerciseWrite a program that displays a random uppercase letter using the Math.random() method.
Begin ExerciseWrite a method that returns a random number between 1 and 54, excluding the numbers passed in the argument.
Begin ExerciseWrite a program that prompts the user to enter a string and displays the string in reverse order
Begin ExerciseWrite a test program that prompts the user to enter ten numbers, invokes the method to reverse the numbers, and displays the numbers.
Begin ExerciseWrite a program that reads ten integers and displays them in the reverse of the order in which they were read.
Begin ExerciseWrite a program that calculates the energy needed to heat water from an initial temperature to a final temperature.
Begin ExerciseWrite a program that prompts the user to enter a year, month, and day of the month, and displays the name of the day of the week.
Begin ExerciseWrite a test program that reads in ten double numbers, invokes the method, and displays the sorted numbers
Begin ExerciseWrite a program that prompts the user to enter values for a, b, and c and displays the result based on the discriminant.
Begin ExerciseWrite a program that prompts the user to enter the number of students, the students’ names, and their scores, and prints student names in decreasing order of their scores.
Begin ExerciseWrite a test program that prompts the user to enter two lists of integers and displays whether the two are strictly identical.
Begin ExerciseWrite a program that reads an integer between 0 and 1000 and adds all the digits in the integer.
Begin ExerciseWrite a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN.
Begin ExerciseWrite a program that prompts the user to enter a social Security number in the format DDD-DD-DDDD, where D is a digit.
Begin ExerciseWrite a program that prompts the user to enter a letter and check whether the letter is a vowel or consonant.
Begin ExerciseWrite a program that prompts the user to enter a temperature between -58F and 41F and a wind speed greater than or equal to 2 and displays the wind-chill temperature.
Begin Exercise