Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out

program in java

VIEWS: 462 PAGES: 8

									My professor said that he wants the OUTPUT for those programs like what I will write bellow:

Program # 1) Enter 20 Integers.
Alpha after reading 20 numbers;
Beta after a call to DoubleArray;
inStock after a call to copyGamma (4 Columns of numbers);
inStock after a call to copyAlphaBeta (4 columns of numbers0.
Enter 10 integers.

Program # 2) Showing Seating chart after each new seat assignment, also, hand-in-intClass and
charClass codes.

Program # 3) Print SecretCode.txt file
Print SecretCodeOut.txt file (2 columns)
Message OK Transmitted.

Program # 4) Show input file (text.txt)
Show OutPut File
Paragraph and Numbers of Lines ?
A count = ?
B count = ?
C count = ?
until Z count = ?
Print Out intClass and CharClass


Anything just e-mail me... Thank you so much my friend.




Program 1: Consider the following statements that are contained in Main:

int [] [] inStock = new int[10][4];

int[] alpha = new int [20];

int[] beta = new int [20];

int[] gama = {11,13,15,17};

int[] delta = {3,5,2,6,10,9,7,11,1,8};



    a) Write the definition of the method inputArray that prompts the user to input 20 numbers and
       stores the numbers in alpha.
    b) Write the definition of the method doubleArray that initializes the elements of beta to 2 times
       the corresponding elements in alpha. Make sure that you prevent the method from modifying
       the elements of alpha.
    c) Write the definition of the method copyGamma that sets the elements of the first row of
       inStock to gamma and the remaining rows of inStock to 3 times the previous row of inStock.
       Make sure that you prevent the method from modifying the elements of gamma.
    d) Write the definition of the method copyAlphaBeta that stores alpha into the first 5 rows of
       inStock and beta into the last 5 rows of inStock. Make sure that you prevent the method from
       modifying the elements of alpha and beta.
    e) Write the definition of the method printArray that prints any one-dimensional array of the type
       int. Print 15 elements per line.
    f) Write the definition of the method setInStock that prompts the user to input the elements for
       the first column of inStock. The method should then the elements in the remaining columns to 2
       times the corresponding element in the previous column , minus the corresponding element in
       delta.

Write a complete Java Program that tests the method main and all of the methods discussed in parts
“a” through “F”. Remember to write Java staments that call each of methods and format the OutPut.

Use the following input for 20 integers: 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2



2) Write a Java Program that can be used to assign seats for MCC Loose-Wing Airline. The Airline has
13 rows, with 6 seats in each row. Rows 1 and 2 are the first class; the remaining rows are economy
class. Rows 1 through 7 are nonsmoking. Your program must prompt the user to enter the following
information:

Use the IntClass ( for row Number) and CharClass ( for Column number) found on the subsequent pages.

Ticket Type ( first class or economy class)

For economy class, the smoking or nonsmoking section.

Desired seat

OutPut the seating plan in the following Form:

                   A B C D E F

Row 1             * * X * * *

Row 2             * * * X * *

Row 3             * * * * * *

Row 4             * * * * * *

Row 5             * * * * * X
Row 6               * * * * * *

Row 7               * * * * * *

Row 8               * X * * * *

Row 9               * * * * * *

Row 10              * * * * * *

Row 11              * * * * * *

Row 12              * * * * * *

Row 13              X * * * * *



Here, * indicates that the seat is Available; X indicates that the seat has been assigned. Make this a
menu-driven program; show the user’s choices and allow the user to make the appropriate choices.
Output the seating chart after each choice is made.

Use as input the fellowing:

Economy, smoking, 8B; first-class, 1C; economy, nonsmoking, 5F; first-class, 2D; economy, smoking,
13A.

public class IntClass

{ private int x;

public IntClass()

{

X = 0;

}

public IntClass (int num)

{

X = num;

}

public void setNum(int num)

{
X = num;

}

public int getNum()

{

Return X;

}

public void addToNum(int num)

{

X = x + num;

}

public void multiplyToNum (int num)

{

X = x * num;

}

public int compareTo(int num)

{

Return ( x – num );

}

public Boolean equals (int num)

{

If ( x = = num)

Return true;

Else

Return false;

}
public String ToString()

{

Return (String.valueOf(x));

}

}




public class CharClass

{

private char ch;

public CharClass()

{

Ch = ` ‘ ;

}

Public CharClass (Char c)

{

Ch = c ;

}

Public void setChar (Char c)

{

Ch = c ;

}

Public int getChat()

{

Return ch;
}

Public char nextChar()

{

Return(char)((int)ch + 1);

}

Public char prevChar()

{

Return(char)((int)ch – 1);

}

Public String ToString()

{

Return (String.valueOf(ch));

}

}



Program # 3: When a message is transmitted in secret code over a transmission channel, it is usually
transmitted as a sequence of bits, i.e.; Os and 1s. Due to noise in the transmission channel, the
transmitted message may become corrupted. This means that the message received at the
destination is not the same as the message transmitted; some of the bits may have been changed.
There are several techniques to check the validity of the transmitted message at the destination. One
technique is to transmit the same message twice. At the destination, both copies of the message are
compared bit-by-bit. If the corresponding bits are the same, the message received is error-free.



Write a Java program that implements a readCode method and compareCode method to check whether
the message received at the destination is error-free. Assume that the secret code representing the
message is a sequence of digits ( 0 to 9) and the maximum length of the message is 250 digits. Also, the
first number in the message is the length of the message. For example , if the secret code is:

79278356

Then the message is 7 digits long, and it is transmitted twice.
The Above message is Transmitted as:

7927835679278356

Use the following Files:

The input File called SecretCode.txt contains the secret code and it copy:

7927835679278356

The Output File called SecretCodeOut.txt should contain 2 columns of digits labeled Code Digit and
Code Digit Copy along with the message underneath both columns that reads: “ Message transmitted
OK.”

Print OUT both input and OUTPUT files along with your source code.



Program # 4:

Write a java program using methods that reads a given text File, OutPuts the text as is, and prints the
number of lines and the number of times each letter appears in the text. An Uppercase letter and a
lowercase letter are treated as being the same; i.e.; they are tallied together.

Since there are 26 letters, use an array of 26 components to perform the letter count. You also need a
variable to store the line count.

The text is stored in a file called Text.txt and is given below. The OutPUt should be stored in a file called
textCh.out.

Use the IntClass in this Program.

Input: The file containing the text to be processed.

Output: The file containing the text, number of lines, and the number of times a letter appears in the
text.

Print out both input and output files along with your source code.

The Contents od Text.txt:

Today we live in an era where information is processed almost at the speed of light. Through
computers, the technological revolution is drastically changing the way we live and communicate with
one another. Terms such as “the Internet “, which was unfamiliar just a few years ago, are very
common today. With the help of computers you can send letters to, and receive letters from, loved
ones within seconds. You no longer need to send a resume be mail to apply for a job; in many cases
you can simply submit your job application via the Internet. You can watch how stocks perform in real
time, and instantly buy and sell them. Students regularly “surf” the internet and use computers to
design their classroom projects. They also use powerful word processing software to complete their
term papers. Many people maintain and balance their checkbooks on computers.

								
To top