INDIA : +91-995-314-1035                                              USA: +1-628-888-9041

                 Rights Reserved - VARCHAS IT SYSTEMS PVT.LTD 

                  Terms and Conditions

privacy policy right reserved research paper

Java Assignment Help | Java Homework Help 

Get Perfect solution and guidence of your Java programming assignments of CSC516 etc. to get higher marks in your examinations.

Salient Features : - 

-> Uniqueness and Plagiarism FREE                             -> We are 24/7 Available

-> Direct Interaction with Our Experts                           -> Live One to One sessions
 

-> Achieve 95+ Score                                                       -> $40 Per Program    

Call : +91-995-3141-035

Java Assignments and  Solutions - 

  1. (10 Points) Write a program SelectWinner.java to pick winners. You have 4 t-shirts and 2 ipads to give away and a pool of 16 students. The students are assigned numbers from 1 to 16. a. Randomly select 4 students to receive the t-shirts. (It is OK to select the same student more than one time) b. Randomly select 2 students to receive the iPads. Make sure to pick two different students. (Make use of loops in your program).

Sample output:

Winners for T-shirts are: Student number 7 9 12 9

Winners for i-Pads are: Student number 5 12

  1. (10 Points) A party planner is organizing a party. Write a program CostEstimate.java that performs the following, • Rental cost is $100. Food cost is as follows: For groups with 1-5 people, cost is $20 per person For groups with 6-10 people, cost is $18 per person For groups with 11-15 people cost is $16 per person For groups with more than 15 people, cost is $15 per person. • Define a method called cost which takes one parameters, the number of people in the party, calculates the per person price (food cost with rental cost), then returns the cost per person. • Call cost method in the program to produce a cost estimate table that shows the party size from 2, 4, up to 20 people.

  2. (10 Points) A person keeps a log of daily spending. Write a program SpendingReport.java that reports the statics of the spending for a week. • Ask user to enter daily spending within the week. (Day 1, Monday, through day 7, Sunday). Save the information in an array. • Calculate the total and the average spending for the week. • Count the total days where spending is higher than the average. • Print out average, total, number of days higher than the average and the day of the week with highest spending.

Sample output:

Enter spending day 1 ($): 25

Enter spending day 2 ($): 16.5

Enter spending day 3 ($): 23.5

Enter spending day 4 ($): 12

Enter spending day 5 ($): 0

Enter spending day 6 ($): 42

Enter spending day 7 ($): 31

Total spending: $ Average: $21.43/day

Number of days above average spending: 4

Highest spending day: Saturday

  1. (10 Points) Design a class called Student. This class is used to represent a student with student id, name and total number of units completed in college. Include standard methods (overloaded constructors, gets, sets, toString) and also include a method that determines the student’s class standing based on number of units completed, a student’s standing is a freshman if completed 30 units or under, a sophomore if completed 31 to 60 units, a junior if completed 61-90 units or a senior (90 units or above). Write out an UML diagram for the Student class. (See a sample in Fig 3.12 on Page 87). Then write Student.java to implement the class design. Write StudentTest.java to create a student object with id as 1234567, name as John Smith, number of units completed as 55.0. Print out the student information including the standing. Then ask user to enter the units completed in current semester, the print the updated information.

 

Sample output:

Student information : Student ID: 1234567

Student Name: John Smith

Total Number of Units Completed: 55.0

Class Standing: Sophomore

Enter Current Semester Units: 12.5

Updated Student information:

Student Name: John Smith

Total Number of Units Completed: 67.5

Class Standing: Junior

Homework 11 COSC_236

--> Download Solution Homework 11 COSC_236

Write a Java documented program to perform the role of a quiz maker. The program should work as follows:

  1. Prompt the student to enter their user name and password. Read a file that contains a list of all students’ information to validate the login credentials.Start the quiz only when the credentials are correct. After 3 failed attempts, exit the program.

  2. Randomly pick ten questions from the TestBank.txtfile.

  3. Display one question at a time. Get the answer then move to the next question.

  4. Do not accept answers other than true or false (T or F should be fine too). The answers should not be case sensitive.

  5. When the user is done with the quiz, print out a report (On screen and on a file) with the below information in it:

    • First name

    • Last name

    • Score

    • Elapsed time

    • User’s answers and the correct answer.

  6. Name the file from step 5 as follows: (userName_COSC_236_Quiz_Date_Time), where:

    • userName is the actual user name of the student who took the quiz.

    • Date_Time is the date and time of the start of the test.

  7. Prompt for another user name and password or done as a user name to exit.

Homework 12

Week 12 Lab Assignment
Please use the starter file from Week 11.

Remember to use modules, proper formatting, comments etc. Be sure to label each output and leave a blank line between each output. Upload you solution as: Week12_Assignment_<LastName>_<Version>.zip (1pt)
1. (3 pts) Write a method using while loop that prints all of the even numbers starting from the value that is provided, down to (but not including) 0. Test your method by using the value 10, such that the output is:
10 8 6 4 2
2. (2 pts) Use a while loop to print this multiplication table:
1 times 10 = 10
2 times 10 = 20
3 times 10 = 30
4 times 10 = 40
5 times 10 = 50
6 times 10 = 60
7 times 10 = 70
8 times 10 = 80
9 times 10 = 90
10 times 10 = 100
3. (3 pts) Use a do while loop to continuously generate a random number from 0 to 99, Stopping once the number 0 is found. When that occurs output the following:
Problem 3 generated <number> random numbers from 0 to 99 before hitting 0. The highest number generated was <number> and the average value was <number>.
4. (3 pts) Set the screen size of 800 and 600 and:
a. Use a for loop to populate 2 arrays for x and y positions such that the array is evenly spaced across the dimension (x or y) 10 times.
b. Use the array length as part of a while loop to populate 100 objects (of your choice) in the world using the co-ordinates generated in 4a

Solution Available.

Homework 13

--> Homework 13 - AsciiArt-CSE 142, Autumn 

Part A: ASCII Art (4 points): The first part of your assignment is to write a program that produces any text art (sometimes called "ASCII art") picture you like.

Write a Java class named AsciiArt in a file named AsciiArt.java. We will share everyone’s art on the class website. Your program can produce any text picture you like, with the following restrictions and details:

The picture should be your own creation, not an ASCII image you found on the Internet or elsewhere.•

The number of lines drawn should be at least 3 but no more than 200, and no more than 100 characters / line.• The picture should not include hateful, offensive, or otherwise inappropriate images.•

The code should use at least one for loop or static method, but should not contain infinite loops.•

The picture must not be identical to your solution for Part B or consist entirely of reused Part B code.•

Your code should not use material beyond Ch. 3 of the book.•

If your Part A program compiles and runs successfully and meets the above constraints, it will receive the full 4 points. Part A will not be graded on style ("internal correctness")

CIS 043 Midterm Exam I - Programming Problems: (40 points)

Download All CIS 043 Solutions

Q 1 . (10 Points) Write a program SelectWinner.java to pick winners. You have 4 t-shirts and 2 ipads

to give away and a pool of 16 students. The students are assigned numbers from 1 to 16.

a. Randomly select 4 students to receive the t-shirts. (It is OK to select the same student

more than one time)

b. Randomly select 2 students to receive the iPads. Make sure to pick two different

students. (Make use of loops in your program).

Sample output:

Winners for T-shirts are: Student number 7 9 12 9

Winners for i-Pads are: Student number 5 12

Q 2 .(10 Points) A party planner is organizing a party. Write a program CostEstimate.java that
performs the following,
• Rental cost is $100. Food cost is as follows:
For groups with 1-5 people, cost is $20 per person
For groups with 6-10 people, cost is $18 per person
For groups with 11-15 people cost is $16 per person
For groups with more than 15 people, cost is $15 per person.
• Define a method called cost which takes one parameters, the number of people in the
party, calculates the per person price (food cost with rental cost), then returns the cost
per person.

• Call cost method in the program to produce a cost estimate table that shows the party
size from 2, 4, up to 20 people. Sample output:
Party Size (#people) Cost Estimate Per Person
2 $70.00
4 $45.00
6 $34.67
8 $30.50
10 $28.00
12 $24.33
….
20 $20.00

Q 3 ..(10 Points) A person keeps a log of daily spending. Write a program SpendingReport.java that
reports the statics of the spending for a week.
• Ask user to enter daily spending within the week. (Day 1, Monday, through day 7,
Sunday). Save the information in an array.
• Calculate the total and the average spending for the week.
• Count the total days where spending is higher than the average.
• Print out average, total, number of days higher than the average and the day of the
week with highest spending.
Sample output:
Enter spending day 1 ($): 25
Enter spending day 2 ($): 16.5
Enter spending day 3 ($): 23.5
Enter spending day 4 ($): 12
Enter spending day 5 ($): 0
Enter spending day 6 ($): 42
Enter spending day 7 ($): 31
Total spending: $ Average: $21.43/day
Number of days above average spending: 4
Highest spending day: Saturday

Q 4 . (10 Points) Design a class called Student. This class is used to represent a student with student
id, name and total number of units completed in college. Include standard methods
(overloaded constructors, gets, sets, toString) and also include a method that determines the
student’s class standing based on number of units completed, a student’s standing is a freshman
if completed 30 units or under, a sophomore if completed 31 to 60 units, a junior if completed
61-90 units or a senior (90 units or above). Write out an UML diagram for the Student class.
(See a sample in Fig 3.12 on Page 87). Then write Student.java to implement the class design.
Write StudentTest.java to create a student object with id as 1234567, name as John Smith,
number of units completed as 55.0. Print out the student information including the standing.
Then ask user to enter the units completed in current semester, the print the updated
information.
Sample output:
Student information :
Student ID: 1234567
Student Name: John Smith
Total Number of Units Completed: 55.0
Class Standing: Sophomore
Enter Current Semester Units: 12.5
Updated Student information:
Student Name: John Smith
Total Number of Units Completed: 67.5
Class Standing: Junior

COSC 236 Part 2 Solution Java Programming

Download COSC 236 Part 2 Solutions Here

 

COSC 236

Part 2

Modify your code from part 1 so that instructors can also use your program. Change your login method to recognize if the username/password entered belong to a student or instructor (based on the last column in the UsersInfo.txt file). If the user is a student, you will need to go with the regular path (start the quiz). If the user is an instructor, display the following options as a menu:

1)      Register a new student.

·         Ask the instructor to entera student’s information: first name, last name, username, email.The password needs to be generated automatically. All the information will then be added to the Users_Info.txt file.

2) Displaystats

·         Display on screen the following stats: the studentwith the shortest duration, highest grade, the lowest grade and average grade of the class. (Hint: upon a successful completion of each quiz, write the student’s name, elapsed time and score to a file, use this to extract the stats listed above).

3) Add new questions

·         Allow the instructor to add new questions to the test bank. The questions can be added in two ways:

1) manually by typing the question and the answer.

2) by providing a file name to be read and appended to the original test bank.

Filter Streams - Java Network Programming Assignment and get Unique Solution

Lab2: Digest Streams and Running Threads

 

The java.security package contains two filter streams that can calculate a message digest for a stream. They are DigestInputStream and DigestOutputStream. A message digest, represented in Java by the java.security.MessageDigest class, is a strong hash code for the stream; that is, it is a large integer (typically 20 bytes long in binary format) that can easily be calculated from a stream of any length in such a fashion that no information about the stream is available from the message digest. Message digests can be used for digital signatures and for detecting data that has been corrupted in transit across the network. In practice, the use of message digests in digital signatures is more important.

 

To calculate a digest for an output stream, you first construct a MessageDigest object that uses a particular algorithm, such as the Secure Hash Algorithm (SHA). You pass both the MessageDigest object and the stream you want to digest to the DigestOutputStream constructor. This chains the digest stream to the underlying output stream. Then you write data onto the stream as normal, flush it, close it, and invoke the getMessageDigest() method to retrieve the MessageDigest object. Finally you invoke the digest() method on the MessageDigest object to finish calculating the actual digest. For example:

 

MessageDigest sha = MessageDigest.getInstance(“SHA”);

DigestOutputStream dout = new DigestOutputStream(out, sha);

byte[] buffer = new byte[128];

while (true) {

    int byteRead = in.read(buffer);

    if (bytesRead < 0) break;

    dout.write(buffer, 0, bytesRead);

}

dout.flush();

dout.close();

byte[] result = dout.getMessageDigest().digest();

 

Calculating the digest of an input stream you read is equally simple. It still isn’t quite as transparent as some of the other filter streams because you do need to be at least marginally conversant with the methods of the MessageDigest class.

 

Your lab assignment is to write a program that calculates the Secure Hash Algorithm (SHA) digest for many files. This is mostly an I/O bound program that is, it spends a lot of time to read in data from hard drive or actually wait for that data since hard drive is slow compared to cpu. This is characteristic of a lot of network programs; they tend to execute faster than the network can supply input. Consequently, they spend a lot of time blocked. This is time that other threads can use, either to process other input sources or to do something that doesn’t rely on slow input. Your assignment can be broken in two phases:

  1. You write a simple program with a single class that reads at least two file (more than one file) and calculates the SHA digest for each file. Then, it prints out the result (digest for each file) on the screen as the following:

annaresume.doc: -16 -110 38 30 -30 -128 -24 68 -101 -97 -113 -109 -27 0 76 -7 126 46 -92 16 sc190.doc: -40 52 65 77 78 116 -54 109 60 -127 -62 67 58 80 -83 5 -35 -1 -78 -40

 

  1. You modify the program such that it uses threads. The idea is to assign a separate thread to process each individual input file.

An example code segment for using a DigestInputStream is shown below (it assumes that an in input file stream (FileInputStream) is already created):

 

MessageDigest sha = MessageDigest.getInstance("SHA");

      DigestInputStream din = new DigestInputStream(in, sha);

        int b;

      while ((b = din.read()) != -1) ;

      din.close();

      byte[] digest = sha.digest();

 

An example for Threads: a thread with a little t is a separate independent path of execution in the virtual machine. A Thread with a capital T is an instance of the java.lang.Thread class. There is a one-to-one relationship between threads executing in the virtual machine and Thread objects constructed by the virtual machine. Most of the time, it’s obvious from the context which is meant if the difference is really important. To start a new thread running in the virtual machine, you construct an instance of the Thread class and invoke its start() method, like this:

 

       Thread t = new Thread();

       t.start();

 

Of course, this thread isn’t very interesting because it doesn’t have anything to do. To give a thread something to do, you either subclass the Thread class and override its run() method, or implement the Runnable interface and pass the Runnable object to the Thread constructor. In both cases, the key is the run() method, which has this signature:

 

       public void run()

 

You’re going to put all the work the thread does in this one method. This method may invoke other methods; it may construct other objects; it may even spawn other threads. However, the thread starts here and it stops here. When the run() method completes, the thread dies. In essence, the run() method is to a thread what the main() method is to a traditional nonthreaded program. A single-threaded program exits when the main() method returns. A multithreaded program exits when both the main() method and the run() methods of all nondaemon threads return. Here is an example thread program:

 

class CountingThread extends Thread {

       public CountingThread(int x) {

              this.x =x;

       }

       public void run() {

              int i=0;

              while (i<15) {

                System.out.println(i);

                     i +=x;

              }

       }

       private int x;

}

 

 

class CountingThreadExample {

  public static void main(String a[]) {

    CountingThread t1 = new CountingThread(2);

    CountingThread t2 = new CountingThread(3);

    t1.start();

    t2.start();

  }

}