in java
Write a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exactly one space (i.e., if a number appears multiple times, it is displayed only once). (Hint: Read a number and store it to an array if it is new. If the number is already in the array, ignore it.) After the input, the array contains the distinct numbers. Here is the sample run of the program:
Enter the numbers: 1 2 3 4 5 6 1
Number of distinct numbers: 6
Numbers: 1 2 3 4 5 6
In: Computer Science
I need answers for question 3 and 4. I believe I'm correct with question 1 and 2 but not sure which could make question 3 and 4 incorrect.
| Coin |
| 7 |
| 6 |
| 4 |
| 6 |
| 4 |
| 6 |
| 4 |
| 6 |
| 4 |
| 4 |
| 3 |
| 5 |
| 5 |
| 6 |
| 3 |
| 3 |
| 5 |
| 6 |
| 3 |
| 7 |
| 5 |
| 2 |
| 6 |
| 6 |
| 6 |
| 3 |
| 3 |
| 7 |
| 2 |
| 4 |
| 6 |
| 5 |
| 6 |
| 6 |
| 7 |
|
Mean: 4.885 Standard deviation: 1.490 |
|
P(x=0) |
P(x=6) |
|||
|
P(x=1) |
P(x=7) |
|||
|
P(x=2) |
P(x=8) |
|||
|
P(x=3) |
P(x=9) |
|||
|
P(x=4) |
P(x=10) |
|||
|
P(x=5) |
4. Give the probability for the following based on the calculations in question 3 above, with the probability of a success being ½. (Complete sentence not necessary; round your answers to three decimal places)
|
P(x≥2) |
P(x<0) |
|||
|
P(x>2) |
P(x≤5) |
|||
|
P(5<x ≤7) |
P(x<5 or x≥7) |
In: Statistics and Probability
Consider “The Big Mac Attack”. Suppose you wish to select a nutritionally complete diet consisting of foods taken from this menu at the least cost. Specifically, suppose you would like to design a diet that provides at least 100% of the U.S.RDA (recommended daily allowance) of vitamins A, C, B, B1, B2, niacin, calcium, and iron, supplies at least 55 grams of protein, contains at most 3 grams of sodium, and provides at most 30% of its calories from fat. (IMPORTANT NOTE: 1 gram of fat contains nine calories)
Please scroll over to see the entire data set.
a.) Using Excel Solver, determine the least cost daily diet that satisfies all of the nutritional requirements mentioned above. (Hint: We also have to make sure that solver doesn’t assign decimals to something that we must buy in whole units).
| Hamburger | McLean Deluxe | Big Mac | French Fries | Chic McNuggets | Honey | Chef Salad | Garden Salad | Egg McMuffin | Wheaties | Vanilla Yogurt | Milk | Orange Juice | Grapefruit Juice | Apple Juice | ||
| Price | ($) | 0.59 | 1.79 | 1.65 | 0.68 | 1.56 | 0 | 2.69 | 1.96 | 1.36 | 1.09 | 0.63 | 0.56 | 0.88 | 0.68 | 0.68 |
| Calories | 255 | 320 | 500 | 220 | 270 | 45 | 170 | 50 | 280 | 90 | 105 | 110 | 80 | 80 | 90 | |
| Protein | (g) | 12 | 22 | 25 | 3 | 20 | 0 | 17 | 4 | 18 | 2 | 4 | 9 | 1 | 1 | 0 |
| Fat | (g) | 9 | 10 | 26 | 12 | 15 | 0 | 9 | 2 | 11 | 1 | 1 | 2 | 0 | 0 | 0 |
| Sodium | (mg) | 490 | 670 | 890 | 110 | 580 | 0 | 400 | 70 | 710 | 220 | 80 | 130 | 0 | 0 | 5 |
| Vit. A | 4 | 10 | 6 | 0 | 0 | 0 | 100 | 90 | 10 | 20 | 2 | 10 | 0 | 0 | 0 | |
| Vit. C | 4 | 10 | 2 | 15 | 0 | 0 | 35 | 35 | 0 | 20 | 0 | 4 | 120 | 100 | 2 | |
| Vit B1 | 20 | 25 | 30 | 10 | 8 | 0 | 20 | 6 | 30 | 20 | 2 | 8 | 10 | 4 | 2 | |
| Vit. B2 | % U.S. RDA | 10 | 20 | 25 | 0 | 8 | 0 | 15 | 6 | 20 | 20 | 10 | 30 | 0 | 2 | 0 |
| Niacin | 20 | 35 | 35 | 10 | 40 | 0 | 20 | 2 | 20 | 20 | 2 | 0 | 0 | 2 | 0 | |
| Calcium | 10 | 15 | 25 | 0 | 0 | 0 | 15 | 4 | 25 | 2 | 10 | 30 | 0 | 0 | 0 | |
| Iron | 15 | 20 | 20 | 2 | 6 | 0 | 8 | 8 | 15 | 20 | 0 | 0 | 0 | 0 | 4 |
In: Finance
Write a program that does the following:
Generate an array of 20 random integers between -100 and 100.
Compute the average of the elements of the array and find the number of elements which are above the average. For example, if the elements of the array were 5 2 4 1 3 then your program should output
The average is 3.0
There are two elements above the average
Find the smallest element of the array as well as its index in the array, and the second smallest element of the array as well as its index in the array. For example, if the elements of the array were 5 2 4 1 3 then your program should output
The smallest element is 1 and its index is 3
The second smallest element is 2 and its index is 1
must be written in Java
In: Computer Science
You will create a program with 3 methods. For the previous homework with three problems, you will create a method for each problem.
In the main method, you will declare the three arrays and create the memory space for each of them. The first method will receive a one dimension array and then it will assign the values ( e.g., a[4] = 4*4*4*4;). The second method receives a 2 dimensional array and creates the calendar. The third method receives a two dimensional array and inverts row 1 in row.
Please note that you already have the bodies of the methods. You are only creating the methods and calling them in the main method.
You will also create methods printOneDimArray; printArrayCalendar; and printTwoDimArray to print each of the arrays.
Previous Homework Instructions
arrayNum [0] = 0
arrayNum [1] = 1
arrayNum [2] = 2*2
arrayNum [3] = 3*3*3
arrayNum [4] = 4*4*4*4
…
arrayNum [10] = 10*10*10…..*10
Hints: a) arrayNum [2] has a value of 4 and arrayNum [3] has a value of 27; b) use one loop to traverse the array and another to calculate the value based on the current index.
Hint: a) use one loop to manage the weeks and another to manage the days of the weeks
previous homework attached below
1) public class Test{
public static void main(String []args){
int[] arrayNum=new int[11];
for(int i=0;i<=10;i++)
{
arrayNum[i]=i;
for(int j=0;j<i-1;j++)
{
arrayNum[i]=arrayNum[i]*i;
}
}
System.out.println("Array is");
for(int i=0;i<=10;i++)
{
System.out.println("arrayNum["+i+"]="+arrayNum[i]);
}
}
}
2) import java.util.Scanner;
import java.util.Arrays;
public class MyClass
{
public static void main(String args[])
{
int [ ] [ ] matrix = new int [5][7];
Scanner sc = new Scanner(System.in);
int days=1;
System.out.println("Assigning Values");
for (int i = 0; i <5; i++)
{
for (int j = 0; j < 7; j++)
{
matrix[i][j] = days++;
if(days==32)
{
break;
}
}
//because day can be 31 only.
if(days==31)
{
break;
}
}
for (int i = 0; i < 5; i++)
{
// Loop through all elements of current row
for (int j = 0; j < 7; j++)
{
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
}
}
3)
import java.util.Scanner;
import java.util.Arrays;
public class MyClass
{
public static void main(String args[])
{
int [ ] [ ] myBiDimArrayNum = {
{ 1, 3, 5 ,7},
{ 0, 0, 0, 0 }
};
Scanner sc = new Scanner(System.in);
int days=1;
System.out.println("Manipulating Array");
for (int i = 0; i <2; i++)
{
//take this variable to copy elements from end of row first.
int last=3;
for (int j = 0; j < 4; j++)
{
//because indexing start from zero 1 will represent row second now
we have to change its content.
if(i==1)
{
//As we have to manipulate the second from ending of row first we
are using ***(i-1) and assign it to second row that is **(i).
myBiDimArrayNum[i][j]=myBiDimArrayNum[i-1][last];
last--;
}
}
}
for (int i = 0; i < 2; i++)
{
// Loop through all elements of current row
for (int j = 0; j < 4; j++)
{
System.out.print(myBiDimArrayNum[i][j] + " ");
}
System.out.println();
}
}
}
In: Computer Science
Consider the following quantum number sets; determine if they can occur together to specify an orbital. If not, indicate which rule has been violated
(a) n=2, l=-1, ml = -1
(b) n=3, l=1, ml=0
(c) n=3, l=3, ml=-3
2: (a) Find all possible subshells in n=4 shell and label these subshells.
2(b): How many total orbitals in shell n=4? what is the relationship between the total number of shell and the quantum number n for that shell?
Please include step-by-step and explanations if possible. I am having a hard time grasping this conce
In: Chemistry
FOR C PROGRAMMING LANGUAGE
Draw the main memory diagram as captured at the end of the C program (i.e. return 0; statement). Your diagram must clearly shows where str, p1, p2, and p3 are pointing to, when the program terminates.
int main(void) {
char str[] = "cs111 NYU"; char* p1 = str;
p1 ++;
char** p2 = &p1;
char* p3 = &str[4];
printf("1. str = %s\n", p1); if(p3 - p1 == 4) {
printf("2. p1 == p3\n"); }
printf("3. char1 %c, char2 %c\n", *(*p2 + 2) + 1, *(*p2 + 2 + 1));
return 0; }
In: Computer Science
|
Sample |
n |
Number of defects in Sample |
Sample |
n |
Number of defects in Sample |
|
1 |
15 |
3 |
6 |
15 |
2 |
|
2 |
15 |
1 |
7 |
15 |
0 |
|
3 |
15 |
0 |
8 |
15 |
4 |
|
4 |
15 |
2 |
9 |
15 |
1 |
|
5 |
15 |
0 |
10 |
15 |
0 |
In: Statistics and Probability
| Elliott Corp. is evaluating a project with the following cash flows: |
| Year | Cash Flow | |||
| 0 | –$ | 20,000 | ||
| 1 | 8,000 | |||
| 2 | 8,800 | |||
| 3 | 9,300 | |||
| 4 | 6,500 | |||
| 5 | – | 6,000 | ||
| Requirement 1: |
| The company uses an interest rate of 9 percent on all of its projects. In the table below, show the modified cash flows and calculate the modified internal rate of return (MIRR) using the "combination" approach. (Do not round intermediate calculations. Negative amounts should be indicated with a minus sign. Round your answers to 2 decimal places (e.g., 32.16).) |
| Year | Combination Approach |
| 0 | $ |
| 1 | $ |
| 2 | $ |
| 3 | $ |
| 4 | $ |
| 5 | $ |
| MIRR | % |
In: Finance
Calculate the Net Present Value given two proposed projects of AIM Manufacturing Corp.
Project # 1:
Initial Investment: $100,000
Cash Inflows:
Year 1: $45,000
Year 2: $48,000
Year 3: $55,000
Year 4: $75,000
Year 5: $150,000
Project # 2:
Initial Investment: $100,000
Cash Inflows:
Year 1: $65,000
Year 2: $45,000
Year 3: $25,000
Year 4: $10,000
Year 5: $1,000
What are the Payback Period for each project using the NPV Method? Which project would you select in you were looking for higher cash inflows in your capital budget? Why....
In: Finance