-45%

COMP 274 COMP274 COMP/274 ENTIRE COURSE HELP – DEVRY UNIVERSITY

$149.99$275.00

COMP 274 COMP274 COMP/274 ENTIRE COURSE HELP – DEVRY UNIVERSITY

COMP 274 Week 1 Homework Assignment

COMP 274 Week 1 ilab Programming Assignment

COMP 274 Week 2 iLab Inheritance and Polymorphism

COMP 274 Week 3 Homework Assignment

COMP 274 Week 3 Programming Assignment

COMP 274 Week 4 Homework Assignment

COMP 274 Week 4 Programming Assignment

COMP 274 Week 5 Homework Assignment

COMP 274 Week 5 Programming Assignment

COMP 274 Week 6 Homework Assignment

COMP 274 Week 6 Programming Assignment

COMP 274 Week 7 Homework

COMP 274 Week 7 Homework Assignment

COMP 274 Week 7 iLab

COMP 274 Week 7 Programming Assignment

Description

COMP 274 COMP274 COMP/274 ENTIRE COURSE HELP – DEVRY UNIVERSITY

COMP 274 Week 1 Homework Assignment

COMP 274 Week 1 ilab Programming Assignment

COMP 274 Week 2 iLab Inheritance and Polymorphism

COMP 274 Week 3 Homework Assignment

COMP 274 Week 3 Programming Assignment

COMP 274 Week 4 Homework Assignment

COMP 274 Week 4 Programming Assignment

COMP 274 Week 5 Homework Assignment

COMP 274 Week 5 Programming Assignment

COMP 274 Week 6 Homework Assignment

COMP 274 Week 6 Programming Assignment

COMP 274 Week 7 Homework

COMP 274 Week 7 Homework Assignment

COMP 274 Week 7 iLab

COMP 274 Week 7 Programming Assignment

COMP 274 COMP274 COMP/274 ENTIRE COURSE HELP – DEVRY UNIVERSITY

COMP 274 Week 1 Homework Assignment

Lecture

Java and C++ Similarities

Chapter 1: Introduction to Computers, Programs, and Java
Sections 1.5, 1.6, 1.7, 1.8, 1.9

Chapter 2: Elementary Programming
Sections 2.3, 2.7, 2.11, 2.13, 2,15, 2.16, 2.18

Chapter 3: Selections
Sections 3.16, 3.17, 3.18, 3.19

Chapter 4: Loops
Section 4.10

Chapter 5: Methods
Sections 5.2, 5.3, 5.8, 5.9, 5.10, 5.11

Chapter 6: Single Dimensional Arrays
Sections 6.1, 6.2, 6.5, 6.6

Create a Word document containing the answers to all the problems given below.

What is the Java source filename extension? What is the Java bytecode filename extension?Write a Java statement to display the string “The value is 100” to a user in a plain dialog box.What is the command you would use to compile the file Addition.java?What is the command you would use to execute the Addition class?What does a Java class contain that identifies it as a Java application?Write a Java statement that declares a constant called MAX which has a value of 1000.How do C++ chars differ from Java chars?Given a double variable called dval, write a single Java statement to prompt the user to enter the price of an item using JOptionPanes, convert the result and store it into dval.Write one Java statement to display the string “The average is xxx” to the console, where the xxx displays the value from the double variable sum divided by 3. Make sure the value is displayed with 3 digits following the decimal point.Write one Java statement to create a string containing “The average is xxx” where the xxx contains the formatted value from the double variable sum divided by 3. Make sure the formatted string contains only 2 digits following the decimal point. Store the formatted string into a String variable called str.Explain the difference between an object reference in Java and an object. Use an example to illustrate your answer.Explain how objects are created in Java and how the memory used by objects is recovered. Compare this to object creation and destruction in C++.Explain how primitive values like doubles are passed between functions in Java. How are string objects passed between functions in Java?How are static methods different from non-static methods? How do you invoke a static method? Give an example of a static method.Write an expression that returns a random value between 1 and 100. The values 1 and 100 must be included in the values that can be returned.Write one Java statement that creates an array of 100 doubles.Write one Java statement that creates an array of integers containing the multiples of 10 between 10 and 100, including 10 and 100.Write one Java statement that would take an array A and copy its contents into array B. Assume that A and B already exist and that B is at least as large as A and that they are both of the same data type.Write a Java method which takes an integer array parameter and locates the minimum value in the array and outputs that value using System.out.printf. Use an enhanced for loop to process the array. You only need one loop to do this!Write a Java method which takes an integer array parameter and fills the array with random numbers between 1 and 1000, including 1 and 1000. Use a traditional for loop to process the array.

Create a Word document containing the answers to all the problems listed above.

COMP 274 COMP274 COMP/274 ENTIRE COURSE HELP – DEVRY UNIVERSITY

COMP 274 Week 1 ilab Programming Assignment

Do the following two programs:

  1. Write a Java application that inputsthree integers from the user and displays the sum, average, product, smallest and largest of the numbers. Use a Scanner object to get the input from the user. Use System.out to output the results. The average should be afloating point result, and should be displayed with 2 digits after the decimal point.
  2. Write a Java application which tests the random number generation abilities of Java. Random number generation is explained below.Your application should simulate rolling a pair of dice some number of times. Use a JOptionPane to ask the user how many times the dice should be rolled. Each dice roll can be a value between 1 and 6, so rolling 2 dice will result in values between 2 and 12. You need to generate a random number between 1 and 6 to simulate rolling each dice. Keep track of the result of each roll using an array that is indexed by the sum of the roll of the two dice. Output your result in a table which shows each value (ie. 2 – 12) and the number of times that value was rolled.

The program must have the following structure:

  1. The main function declares the counting array and gathers input from the user.
  2. A separate function is called which takes an integer array parameter as well as the number of dice rolls to execute. This function rolls the dice the required number of times and uses the array provided to count the number of times each value is rolled.
  3. The main program takes the count data from the array, formats it and displays it as described above.

For output, you should build a formatted string which includes tabs and new lines to represent your table. JOptionPanes by themselves are not capable of properly formatting tabs. However, there is another Java class which can be used with JOptionPanes to correctly display a formatted string. The JTextArea class understands all string formatting instructions. The following illustrates how to use the JTextArea class with a JOptionPane to display a formatted string.

#import javax.swing.JOptionPane;

#import javax.swing.JTextArea;

String output = “This \t is \t a \t formatted \t string. \n”;

// Create a new JTextArea object

JTextArea area = new JTextArea( );

// Place a formatted string into the JTextArea

area.setText( output );

// Place the text area into the JOptionPane

JOptionPane.showMessageDialog( null, area, “Title for dialog box”, JOptionPane.INFORMATION_MESSAGE );

For each of the two programming problems, create an Eclipse project and develop a Java program to solve the problem. Make sure to capture a sample of your program’s output. The best way to do this is to click on the console window you want to capture and then press the Alt and PrintScreen keys at the same time. Then paste your captured screen image into a Word document. For each of the two programs, put the screen capture followed by a copy of your source code into your Word document.

Random Numbers in Java

There are two different classes available to generate random numbers in Java. The static method random from the Math class can be used to generate a random floating point number from 0 up to but not including 1. This number can be scaled to whatever range of random numbers is desired.

(int)(Math.random( ) * 10); //results in an integer between 0 and 9

The Random class from the java.util package can also be used to get random numbers. The nextInt method returns an integer from 0 up to but not including the argument value provided to the nextInt method.

Random rand = new Random( );
int number = rand.nextInt(10); //results in an integer between 0 and 9

minimumValue + differenceBetweenValues * rand.nextInt(scalingFactor )

The formula shown above is used to generate a range of random numbers starting at some minimum value and generating some specified number of random values. The scalingFactor determines how many different random values will be generated by the call to nextInt, starting with the value 0. The difference between values is usually 1.

Your final programming document should contain in the following order:

1. Screen capture of the first program followed by source code.

2. Screen capture of the second program followed by source code.

3. Submit this as the Week 1 Programming Solution.