Question
1. Write a method lettertoWeightedGrade to convert a letter grade to weighted grade. For example, the weighted grade of letter grade 'A' or 'a' is
1. Write a method lettertoWeightedGrade to convert a letter grade to weighted grade. For example, the weighted grade of letter grade 'A' or 'a' is 4, the weighted grade of letter 'B' or b' is 3, for 'C' or 'c', it is 2, for 'D' or 'd', it is 1, for 'F' or f, it is 0. For any other letter, return-1.
Call the above method to find out the weighted grade of letter grade of 'A' and 'K.
2. Write a method i sodd to find out whether an integer is even or not. If it is odd, then return true, otherwise, return false. An integer is odd if it cannot be divided by 2 (or the remainder of that integer divided by 2 is 1).
3. Write a method to reverse a string. For example, if the given string is "abc" your method should return "cba". You may need to use the following methods from String class
public int length ()
Returns the length of this string. The length is equal to the number of Unicode code units in the string.
public char charAt (int index)
Returns the char value at the specified index. An index ranges from o to length)1. The first char value of the sequence is at index 0, the next at index 1, and so on, as for array indexing.
Hints:
The index of the first letter of a string starts from 0.
You may use charAt method of String class to extract one letter a time, then construct the reversed string.
2. 5 points] Write Accountciient method to test Account class you defined.
(1) Create an account with default constructor,
(2) Change its balance to 5
(3) Change its balance to -5.
(4) Print out the above account.
(5) Create another account with your name and balance of 100, compare the tw accounts equals or not.
Step by Step Solution
3.59 Rating (170 Votes )
There are 3 Steps involved in it
Step: 1
1 Letter Grade to Weighted Grade public static int letterToWeightedGradech...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started