Question

JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in...

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".

Homework Answers

Answer #1

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);
   }

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
. Write a function in python that accepts a sentence as the argument and converts each...
. Write a function in python that accepts a sentence as the argument and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin, you remove the first letter and place that letter at the end of the word. Then you append the string “ay” to the word. Here is an example: English: I SLEPT MOST OF THE NIGHTPIG LATIN: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY.
Please write a program that reads the file you specify and calculates how many times each...
Please write a program that reads the file you specify and calculates how many times each word stored in the file appears. However, ignore non-alphabetic words and convert uppercase letters to lowercase letters. For example, all's, Alls, alls are considered to be the same words. What is the output of the Python program when the input file is specified as "proverbs.txt"? That is, in your answer, include the source codes of your word counter program and its output. <proverbs.txt> All's...
Lab Assignment | Count vowels Write a program that will use a while loop to count...
Lab Assignment | Count vowels Write a program that will use a while loop to count and display the number of vowels in the string provided as input by the end-user. This program will consider the letters a, e, i, o, and u (both upper and lower case) to be vowels. The user may enter a single word, a sentence, a paragraph, or nothing at all as input. Be sure to test each possibility. Python 3 please!
Write a Java Program, that opens the file "students.txt" The program must read the file line...
Write a Java Program, that opens the file "students.txt" The program must read the file line by line The program parses each line that it reads For example, for this line: 1:mohamed:ali:0504123456:cs102:cs202 The program must print    >ID = 1    >First Name = Mohamed   >Last Name = Ali   >Mobie = 0504123456   >Courses = cs102, cs202 In addition, it adds the mobile phone number into an ArrayList called studentPhoneList Print the content and the size of studentPhoneList Show your results and provide...
c# please Create a “Main” program which reads a text file called “collectionOfWords.txt”. Include exception handling...
c# please Create a “Main” program which reads a text file called “collectionOfWords.txt”. Include exception handling to check if the file exists before attempting to open it. Read and print each string to the console. Next modify each word such at the first letter in each word is uppercase and all other letters are lowercase. Display the modified word on the console. Creating a text file: Open up Notepad and type in the following words. Save the file as collectionOfWords.txt...
Write a program that accepts an input string from the user and converts it into an...
Write a program that accepts an input string from the user and converts it into an array of words using an array of pointers. Each pointer in the array should point to the location of the first letter of each word. Implement this conversion in a function str_to_word which returns an integer reflecting the number of words in the original string. To help isolate each word in the sentence, convert the spaces to NULL characters. You can assume the input...
Program Behavior Each time your program is run, it will prompt the user to enter the...
Program Behavior Each time your program is run, it will prompt the user to enter the name of an input file to analyze. It will then read and analyze the contents of the input file, then print the results. Here is a sample run of the program. User input is shown in red. Let's analyze some text! Enter file name: sample.txt Number of lines: 21 Number of words: 184 Number of long words: 49 Number of sentences: 14 Number of...
Project File Processing. Write a program that will read in from input file one line at...
Project File Processing. Write a program that will read in from input file one line at a time until end of file and output the number of words in the line and the number of occurrences of each letter. Define a word to be any string of letters that is delimited at each end by either whitespace, a period, a comma or the beginning or end of the line. You can assume that the input consists entirely of letters, whitespaces,...
JAVA PROGRAMMING: Write a program called TimeSymbolTables that creates three symbol tables, each of a different...
JAVA PROGRAMMING: Write a program called TimeSymbolTables that creates three symbol tables, each of a different implementation. Each symbol table will contain as a key a word read from a text file and as a value the number of times that word occurs in the text file. Have the program fill the first symbol table with these counts, keeping track of how long that takes using a Stopwatch object. It then does the same thing with the second symbol table....
WRITE A JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's...
WRITE A JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's profit (or loss) within a certain period of time. 1) First, the program need to get user's name, the stock's code, number of shares and the price he/she purchased the stock, it also asks the user for the price he/she sold the stock later on. The program then compute the following: The amount of money the customer paid for the stock. The amount of...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT