Task A:
Use the following program:Program or Class Name:
Description of program or class: What does it do? How do you use it?
Author: [your name]
Date:
*/
import java.util.Scanner;
public class TaskA {
public static void main(String[ ] args) {
System.out.print("Enter a word: ");
// declare Scanner objects that accept standard input
// https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html
Scanner so = new Scanner(System.in);
String word = so.nextLine();
String[] chars = word.split("");
System.out.println("The word entered is: " + word);
}
}
Edit, compile, and run the program. Then modify the program to print out only the first and last
letters of the entered word.
Task B:
Modify the program in task 1 by adding specialized methods to accomplish each of the following onthe word input by the user:
- 1. Converts each character of the entered word into an array of Unicode decimal numbers (See: http://unicodelookup.com )
- Determines if the input word is a palindrome – the same frontwards and backwards.
- Sorts the Unicode character array according to their Unicode decimal values.
- Computes the max, min, sum and average of the Unicode values of the characters in the entered word. Displays items 1 through 4 as processing occurs.
- To accomplish item 2, consider using one or more loops so that elements of an array can be compared.
For item 3, if an array's value in the outer loop is greater than that of the inner loop, the values are
swapped. This is a bubble sort – more here: http://mathbits.com/MathBits/Java/arrays/Bubble.htm
(Don't use one of the built-in sort methods; you need to code your own, as shown at the link.)
Task C:
Modify the above program two analyze two words as input by theuser.
- For each unique letter in input word 1, the program prints the frequency of its occurrence in input word 2.
- The output includes a histogram, like that pictured on page 295 of your textbook. The above three tasks are equally weighted for points. Submit your three .java source code files (TaskA.java, TaskB.java, and TaskC.java) for your three working programs on D2L at Assignments /Assessments / Programming Assignment 1
Get your solution now:
- via WhatsApp: +92-324-7042178
- via email: codelogixstudio@gmail.com
Comments
Post a Comment