
Watch this post - more to come!
- You are to complete an exercise similar to 8.10, p 298. The class name must be QuadraticEquation. This class will have no main and will be tested against my own driver program. Any input/output must be done at the command line.
The private data members must be:
doubles:
a // coefficient of x^2
b // coefficient of x
c // constant
d // discriminant
These are the required function headers:
private helper functions:
private double calculateDiscriminant()
constructor:
public QuadraticEquation(double coA,
double coB, double coC)
non-static public functions:
public double getRoot1()
public double getRoot2()
public boolean displayRoots()
accessor functions:
public double getA()
public double getB()
public double getB()
public double getDiscriminant()Sample OutputHere is a screenshot of my code running. - Morse Code is the representation of individual characters and numerals as a series of dots and dashes. Write a program which reads in an integer from the user and converts it to an array of individual digits which are then printed out on the console using their Morse codes.
You should use the following constant String array in your code:
public static final String MORSE_CODE[] = {
"-----",// zero
".----",// one
"..---",// two
"...--",// three
"....-",// four
".....",// five
"-....",// six
"--...",// seven
"---..",// eight
"----." };// nine
These are the required function headers:
public void printMorseCode()
public static MorseCodeNos[]
convertToMorseCode(int n)
public static void
printArray(MorseCodeNos[] mcn)
An object of type MorseCodeNos has a single private data member, morse, which is of type String.Sample OutputHere is a screenshot of my code running. - Write a program which reads in the user's name as "first mi last" then creates from that string a phone book style entry, "last, first mi". You must write two methods.
These are the required function headers:
public static String getFullName()
public static String
assemblePhoneBookEntry(String full)
You will need to make use of the StringBuilder class and at least two of the manipulation methods of the String class.Sample OutputHere is a screenshot of my code running. - Write a program, StringStats, which prompts the user to enter a string and then reports back to the user statistics about their string. Your program should have one method to get the user's input string and one method that can be used to determine how many spaces, or how many lowercase characters, or how many uppercase characters, or how many digit characters are in the string. This class uses several methods from the Character class: isSpaceChar, isUpperCase, isLowerCase, isDigit.
These are the required function headers:
public static String getLine()
public static int countItem(String s,
char item) - Write a program, Vowels, which prompts the user to enter a string and then reports back to the user how many vowels (upper-and lowercase) are in their string. Your program should have one method to get the user's input string and one method that can be used to determine how many vowel characters are in the string.
These are the required function headers:
public static String getLine()
public static int countVowels(String s)Sample OutputHere is a screenshot of my code running. - Write a program, SimplePunctuation, which prompts the user to enter a string and then reports back to the user how many punctuation marks are in their string. Your program should have one method to get the user's input string and one method that can be used to determine how many punctuation marks are in the string. For the sake of simplicity, you may limit your detection to the punctuation marks in the set { , . ? !}
These are the required function headers:
public static String getLine()
public static int countPunct(String s)Sample OutputHere is a screenshot of my code running. - Write a program, Words, which prompts the user to enter a string and then reports back to the user how many words are in their string. Your program should have one method to get the user's input string and one method that can be used to determine how many words are in the string. You'll need to strip out any digits in your user's string.
These are the required function headers:
public static String getLine()
public static int countWords(String s)Sample OutputHere is a screenshot of my code running. - Write a GUI application that reads in an unknown number of test scores from a text file, sums the scores, and reports the average and the number of scores to the user. You may make use of the JFileChooser class, if you like.
These are the required function headers:
public static File getFile()
throws Exception
public static void wrangleTestScores(
File file) throws Exception
public static void main(String[] args)
throws ExceptionSample OutputHere is a screenshot of my code running. - At Gringotts Wizarding Bank, currency comes in bronze Knuts, silver Sickles, and golden Galleons.
1 Galleon = 17 Sickles and 1 Sickle = 29 Knuts
One Galleon is equivalent to $7.83 at current exchange rates. Write a GUI program called CurrencyConverter to calculate how many Galleons, Sickles, and Knuts you should receive in return for $100, using the minimum number of coins possible.
These are the required function headers:
public static int getDollars()
public static String convert(int cash)Sample OutputHere are screenshots of my code running. - Write a program that uses a regular expression to test the validity of a US ZIP code.
These are the required function headers:
public static String getZip(Scanner input)
public static boolean isValid(
String zipcode)Sample OutputHere are screenshots of my code running.

Quadratic Equation driver output

Morse Code Nos output

Phone Book output
Sample Output
Here is a screenshot of my code running.
String Stats output

Vowels output

SimplePunctuation output

Words output

Gooey Grades output

Currency Converter input

Currency Converter output

Zip Code valid 5-digit output

Zip Code valid 9-digit output

Zip Code invalid output