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
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...
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...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total...
C Program Write a program to count the frequency of each alphabet letter (A-Z a-z, total 52 case sensitive) and five special characters (‘.’, ‘,’, ‘:’, ‘;’ and ‘!’) in all the .txt files under a given directory. The program should include a header count.h, alphabetcount.c to count the frequency of alphabet letters; and specialcharcount.c to count the frequency of special characters. Please only add code to where it says //ADDCODEHERE and keep function names the same. I have also...
write a program that automates the process of generating the final student report for DC faculty...
write a program that automates the process of generating the final student report for DC faculty considering the following restrictions. Consider declaring three arrays for processing the student data: studID studName studGrade The student ID is a random number generated by the 5-digit system in the range of (10000 - 99999). Create a function to assign the student ID generated in an array of numbers. Consider the following to generate the random number: Add the libraries: #include <stdlib.h> #include <ctime>...
Note: Do not use classes or any variables of type string to complete this assignment Write...
Note: Do not use classes or any variables of type string to complete this assignment Write a program that reads in a sequence of characters entered by the user and terminated by a period ('.'). Your program should allow the user to enter multiple lines of input by pressing the enter key at the end of each line. The program should print out a frequency table, sorted in decreasing order by number of occurences, listing each letter that ocurred along...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
In this assignment you will write a program that compares the relative strengths of two earthquakes,...
In this assignment you will write a program that compares the relative strengths of two earthquakes, given their magnitudes using the moment magnitude scale. Earthquakes The amount of energy released during an earthquake -- corresponding to the amount of shaking -- is measured using the "moment magnitude scale". We can compare the relative strength of two earthquakes given the magnitudes m1 and m2 using this formula: f=10^1.5(m1−m2) If m1>m2, the resulting value f tells us how many times stronger m1...
Write a program of wordSearch puzzle that use the following text file as an input. The...
Write a program of wordSearch puzzle that use the following text file as an input. The output should be like this: PIXEL found (left) at (0,9). ( Use JAVA Array ) .Please do not use arrylist and the likes! Hints • The puzzle can be represented as a right-sized two-dimensional array of characters (char). • A String can be converted into a right-sized array of characters via the String method toCharArray. . A word can occur in any of 8...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT