COMP 274 COMP274 COMP/274 Week 1 Lab – DeVry University

Page 1

COMP 274 COMP274 COMP/274 Week 1 Lab – DeVry University

DOWNLOAD SOLUTION https://www.solvedcollegepapers.com/product/comp-274-comp274-comp-274-ity/ Do the following two programs: 1. Write a Java application that inputs three 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 a floating 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. Category: Assignments Help Experts Tags: COMP 274 COMP274 COMP/274 Application Programming with Lab - DeVry University, COMP 274 Entire Course, comp 274 week 1, COMP 274 Week 1 Lab, comp 274 week 2, COMP 274 Week 2 Lab Inheritance and Polymorphism, comp 274 week 3, COMP 274 Week 3 Lab Java Application GUI, comp 274 week 4, COMP 274 Week 4 Lab Java Program to Convert Temperature, comp 274 week 5, COMP 274 Week 5 Lab Timer and Mouse Events and Java Graphics, comp 274 week 6, COMP 274 Week 6 Lab Calendar Program, comp 274 week 7, comp 274 week 7 lab, COMP 274 Week 7 Lab Java Doc, comp 274 week 7 programming assignment, COMP 274comp 274, COMP 274comp 274 week 7, comp274 week 7, java 

Description

Description


COMP 274 Week 1 Lab – DeVry University Do the following two programs: 1. Write a Java application that inputs three 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 a floating 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. Download Full Course Solution: ENTIRE ONLINE CLASS HELP EACH-CHAMPLAIN COLLEGE https://www.solvedcollegepapers.com/product/entire-online-class-help/ Entire Online classes help: book @125 per Week. All Done from Scratch

Download Full Course Solution: IT/IT 212 IT212 IT/212/Recommendation of local area network topology https://www.solvedcollegepapers.com/product/it-212-it212-lan-topology/ Overview In Milestone One, you will: -Given the provided scenario, explain the key considerations (must-haves) and constraints of the networking project at the firm’s new location. -Then make a well-reasoned recommendation of local area network (LAN) topology.


You have been asked for your input regarding the new Fayetteville, NC, office setup project. Conduct research and deliver a report to the team with key considerations and recommendations for the setup of the network infrastructure. Fayetteville office will be home to 50 employees, including the new executive vice president of sales and marketing. All possible sites have offices located in an office building with access to fiber, cable, and T1 internet service providers. The site must support live video teleconferencing calls with employees based at the other sites. It must also reliably send print jobs to billboard printers located in the company headquarters. Download Full Course Solution: BUS 303 Human Resource Management Entire Course Help https://www.solvedcollegepapers.com/product/bus-303-human-resource-managemententire-course-help/ BUS 303 Human Resource Management Entire Course Help> Ashford University Bus 303 Human Resource Management Week 1 Quiz 1.docx Bus 303 Human Resource Management Week 1 Quiz 1.docx BUS 303 – Fall 2018 Bus 303 Human Resource Management Week 1 Quiz 1.docx 5 pages BUS 303 Week 1 quiz.docx Download Full Course Solution: [New Answers]-Full course CMIT-200: Relational Database Design and SQL https://www.solvedcollegepapers.com/product/cmit-200-relational-database-design-andsql/ Course Description and Prerequisites A relational database management system (RDBMS) is the heart of most modern information systems. This is a survey course in relational database design, development, and implementation. The course covers key concepts of database design using entity relationship diagrams (ERDs), normalization, and functional dependence. Logical and physical schemas and the use of Structured Query Language (SQL) to query data will be studied in depth. Student learning is reinforced through discussions and hands-on laboratory assignments. Students will complete a relational database project by using a relational database management system. This course is intended for anyone who is involved in designing, developing, or implementing relational database management systems (e.g., users, IT managers, technical staff, and other IT team members).


Prerequisite: CMIT-135 Student-Centered Learning Outcomes      

Design a relational database using entity relationship diagrams and SQL Normalize relational database tables through third normal form (3NF) Differentiate between conceptual, logical, and physical database designs Specify different types of relationships between database entities and objects Physically create databases using SQL Data Definition Language (DDL) Query databases using SQL Data Manipulation Language (DML)


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.