JAVA ASSIGNMENT
1. Write program that opens the file and process its contents. Each lines in the file contains seven numbers,which are the sales number for one week. The numbers are separated by comma.The following line is an example from the file 2541.36,2965.88,1965.32,1845.23,7021.11,9652.74,1469.36. The program should display the following:
. The total sales for each week
. The average daily sales for each week
. The total sales for all of the weeks
.The average weekly sales
.The week number that had the highest amount of sales
.The week number that had the lowest amount of sales
2. Many compnaies use telephone numbers like 555-GET-FOOD so the number is easier for the customer to remember. On a standard telephone,the alphabetic letters are mapped to numbers in the following fashion
A,B, and C=2
D,E and F=3
J,K and L=5
M,N and O=6
P,Q,R and S=7
T,U,and V=8
W,X,Y and Z=9
write an application that asks the user to enter a 10-character telephone number in the format xxx-xxx-xxxx. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent.For example,if the user enters 555-GET-FOOD the application shoudl display 555-438-3663
3. write a program that reads a sentence as an input and converts each to "pig Latin". In one version of pig Latin,you convert a word by removing the first letter,placing that letter at the end of the word,and then appending "ay" to the word.Here is an example
ENGLISH: I SLEPT MOST OF THE NIGHT'
PIG LATIN: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY
4. Morse code is a code where each letter of the English alphabet ,each digit,and various,punctuation characters are represented by a series of dots and dashes.Shows part of the code.Write 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.
5.write a program that accept as input a sentence in which all of the words are run together,but the first character of each word word is uppercase. covert the sentence to a string in which the words are separated by space and only the first word starts with uppercase letter.For example,the string"StopAndSmellTheRoses".would be converted to "Stop and smell the roses".
5) Executable code:
import java.util.Scanner;
public class Wordseparator {
public static void main(String[] args) {
Scanner scan = new
Scanner(System.in);
System.out.print("Enter the
sentence: ");
String s = scan.next();
String resultStr = "";
for (int i = 0; i < s.length();
i++) {
char ch =
s.charAt(i);
if (i == 0)
{
resultStr = resultStr +
String.valueOf(ch).toUpperCase();
} else {
if (Character.isUpperCase(ch)) {
resultStr = resultStr + "
";
}
resultStr = resultStr +
String.valueOf(ch).toLowerCase();
}
}
System.out.println(resultStr);
}
}
Get Answers For Free
Most questions answered within 1 hours.