Createa console program prompts the user to input length


Assignment:

Task:

You must identify yourself by including Java comment block at the beginning of your program source code. This comment block must include your name, the date, the assignment number, and your student identification number. You also must provide a description and list of key variables and parameters used.

An example of the minimum Java comment block is:

/**
* Name: Who you are.
* Date: When you did the work.
* Assignment: Number
* Student Number: AAXXXXXXX
* Description: This program does a, b, and c.
*/

You must name your Java class files (your source code) by concatenating the assignment number (A1 through A4) and your student identification number. For example, if your student number were AB7654321, the your Java class file would be named: A1AB7654321...A7AB7654321

If any assignment fails to compile cleanly, it must be reworked. It will be embarrassing if any of your programs were to fail to compile because the filename and class name did not agree.

In naming your variables, it is essential that you use an acceptable, consistent style and reasonable variable names. Variable names like x, y, and z are to be avoided. If your program needs to compute a total, then an appropriate variable for storing the value would be total or totValue or another meaningful identifier.

Using the defacto standard style for naming and indenting is a good idea, but not required. What is required is that the style you use is consistent, easily readable, and structured. If you don't have a personal style, follow the the style you see throughout the textbook.

In addition, when you declare an important variable, place an inline comment using //, followed by a brief explanation of the variable's use in the program. For example:
int idxR = 0; // Row Index

float inpLen = 0.0; // Input Length

Finally, your .java file must be in plain text suitable for editing using Notepad. It must not have embedded tabs or graphic characters. If you edit your file using an operating system that does not included a carriage return and line feed at the end of each line (Linux), then you must state that in each submission so the instructor knows to convert it -- the instructor looks at every submission, line by line, in Notepad!

Assignment 1

Write a console program that prompts the user to input the length and width of a rectangle and then prints the rectangle's area and perimeter. Note that a "console program" is one that is runnable from the MS-DOS command prompt.

Assignment 2

Write a console program that:

1. Uses a while loop to perform the following steps:

1. Prompt the user to input two integers: firstNum and secondNum where secondNum is at least 10 greater than firstNum, both numbers are positive integers, and secondNum is less than 1000.

2. Verify that the user entered acceptable numbers, and if not, provide error feedback and prompt them again.

3. Output all results to a file in the same directory as the program, placing an appropriate label between each section of output. Note that your program must be able to run repeatedly overwriting the file from the previous run.

4. Output all odd numbers between firstNum and secondNum inclusive, one number per line.

5. Output the sum of all numbers between firstNum and secondNum exclusive.

2. Uses a for loop to perform the following steps:

1. Continue writing to the same file as before.

2. Write a label as before.

3. Output all numbers from secondNum to firstNum in a single line with commas separating the numbers.

3. Write the date and time as the last line in the file in the format yyyy-mm-dd hh:mm:ss.

Assignment 3

Write a program that consists of three classes. The first class will be the actual program.

The second class will simply convert a string to lower case.

The third class will have three methods:

public static String trimmed(String str)

and

public static String trimmed(String str, int len)

and

public static String squeeze(String str)

The 1st trimmed method will return str without leading or trailing whitespace and will return an empty string if str is null.

The 2nd trimmed method will return the first len characters after trimming the string. The 2nd method must make use of the 1st method.

The squeeze method will replace all sequences of 2 spaces with 1 space.

The program will read a file containing the data below (cut and paste it into notepad and save it), and will display each line:

1. as entered but trimmed and squeezed.

2. as entered but trimmed, squeezed, and shortened to 10 characters

3. as entered but trimmed, squeezed, converted to lower case, and shortened to 20 characters.

This test is a test of your Java programming skills!

xyz

ABCDEFGHIJKLMONPQRSTUVWXYZ1234567890-=_+ !

end data

Assignment 4

Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed). As they enter the data, assign it to a two-dimension array where the first dimension contains exactly what they type and the second dimension contains the first non-whitespace character of what they type, in lowercase. If they enter a blank line, it is acceptable to skip that line.

When they type done, do these steps:

1. display: As Entered

2. for each entry in the array, display the index of the first dimension, the second dimension's value, and the first dimension's value on a single line separated by : (colon).

3. display: Bubble Sorted

4. using a bubble sort, for each entry in the array, display the original index of the first dimension, the second dimension's value, and the first dimension's value on a single line separated by : (colon) sorted by the second dimension.

5. display: Selection Sorted

6. using a selection sort, for each entry in the array, display the original index of the first dimension, the second dimension's value, and the first dimension's value on a single line separated by : (colon) sorted by the first dimension.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Createa console program prompts the user to input length
Reference No:- TGS01934308

Now Priced at $30 (50% Discount)

Recommended (96%)

Rated (4.8/5)