Question
Objectives:
* Practice with arithmetic operators
* Learn how to write prompts
* Learn how to read input from the user
Write a complete program that will have 2 major components. The first part is to calculate and display a list of all the prime numbers up to and including 100. The second part is to test any integer type that is input to see if it is a prime number. If it is not prime, you should also determine what a factor of the number is. The user should be allowed to choose which portion to run and there should be a process for allowing multiple tests.
Your output from part 1 should be a listing of all the prime numbers in the interval.
For part 2, your output should be similar to the following.
If the number is not prime:2147613787 is not prime, it has a factor of 11 and if it is prime:47 is prime
For part 2, you should test the following numbers: 47, -37, 1, 421361, 9877897541
Wind Chill
Objectives:
* Practice with arithmetic operators
* Practice with 2-D arrays
* Practice with if/else
* Practice with formatting output
Write a program that will display a table of wind chill effects. The temperatures should range from a minimum of -15° F to a maximum of 60° F. The wind speeds should range from 0 mph to 50 mph. For your table, each parameter should increase in increments of 5 units.
Windchill is computed according to the following piecewise function:
temp , wind <=4
equivalent temp = 91.4 - (10.45 + 6.69 * sqrt(wind) -.447 * wind)*(91.4-temp)/22, 4 < wind <= 45
1.6 * temp -55, wind > 45
You should complete all calculations and fill your 2-d array before printing. The output generated from this program should be a well formatted table with appropriate row and column labels. Equivalent temperatures should be rounded to the nearest integer.
Cards
Objectives:
* Practice with designing and developing classes
* Practice with arrays/arraylists
* Practice with random number generation
Write a class Card, a class CardDeck and a client to test them. The card class should have default and overloaded constructors and at least 2 attributes, a value and a suit, e.g. Ace Clubs or 4 Diamonds. The CardDeck class should have a constructor, an attribute that can store all of the cards and methods to shuffle and/or deal the cards at random and reset the card deck. Your client program should deal 5 hands after shuffling the cards to demonstrate that the cards are dealt in random, re-shuffle the deck and deal 5 more hands.
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
import java.util.Scanner;public class prime {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("part 1");
System.out.println("Prime list:");
for (int i = 1 ; i <= 100; i++) {
if (isPrime(i)) {
System.out.print(i + " ");
}
}
System.out.println("");
System.out.println("Part 2");
System.out.println("Test");
int [] test = {47, -37, 1, 421361, 987789751};
for (int i = 0; i < test.length; i++) {
if (isPrime(test[i])) {...