전체 글(37)
-
Coding Exercise 28: Paint Job
Bob is a wall painter and he needs your help. You have to write a program that helps Bob calculate how many buckets of paint he needs to buy before going to work. Bob might also have some extra buckets at home. He also knows the area that he can cover with one bucket of paint. 1. Write a method named getBucketCount with 4 parameters. The first parameter should be named width of type double. This..
2021.04.04 -
Coding Exercise 27: Input Calculator
Wrtie a mtehod called inputThenPrintSumAndAverage that does not have any parameters. The method should not return anything and it needs to keep reading int numbers from the keyboard. When the user enters something that is not an int then it needs to print a message in the format "SUM = XX AVG = YY". XX represents the sum of all entered numbers of type int. YY represents the calculated average of..
2021.04.03 -
Coding Exercise 26: Diagonal Star
Write a method named printSquareStar with one parameter of type int named number. If number is < 5, the method should print "Invalid Value". The method should print diagonals to generate a rectangular pattern composed of stars (*). This should be accomplished by using loops. public class DiagonalStar { public static void printSquareStar(int number){ if(number < 5) { System.out.println("Invalid V..
2021.04.03 -
Coding Exercise 25: Largest Prime
Write a method named getLargestPrime with one parameter of type int named number. If the number is negative or does not have any prime numbers, the method should return -1 to indicate an invalid value. The method should calculate the largest prime factor of a given number and return it. public class LargestPrime { public static int getLargestPrime(int number) { if (number < 2) { return -1; } for..
2021.04.02 -
Coding Exercise 24: Flour Park Problem
Write a method named canPack with three parameters of type int named bigCount, smallCount, and goal. The parameter bigCount represents the count of big flour bags (5 kilos each). The parameter smallCount represents the count of small flour bags (1 kilo each). The parameter goal represents the goal amount of kilos of flour needed to assemble a package. Therefore, the sum of the kilos of bigCount ..
2021.04.01 -
Coding Exercise 23: Number to Words
Write a method called numberToWords with one int paramter named number. The method should print out the passed number using words for the digit. If the number is negative, print "Invalid Value". To print the number as words, follow these steps: 1. Extract the last digit of the given number using the remainder operator. 2. Convert the value of the digit found in Step 1 into a word. There are 10 p..
2021.03.31