thumbs up ONLY for correct answer.
thank you.
Hi,
I am using C to implement the above psuedo code since it is widely used and easy to understand.
#include <stdio.h>
int main()
{
float n;
float s=0;
float x;
float c=0;
printf("Input n \n");
scanf("%f", &n);
for(int i =1; i<=1000; i++){
for(int j=1; j<=n; j++){
x = 0.5;
s = s+x;
}
if((s/n>0.45)&&(s/n<0.55)){
c = c+1;
s=0;
}
}
float a = c/1000;
printf("%f",a);
return 0;
}
Or we can use
#include <stdio.h>
#include<stdlib.h>
int main()
{
float n;
float s=0;
float x;
float c=0;
printf("Input n \n");
scanf("%f", &n);
for(int i =1; i<=1000; i++){
for(int j=1; j<=n; j++){
x = (((float) rand() / RAND_MAX) * 0.10) + 0.45; //generating
random decimal between 0.45 and 0.55
s = s+x;
}
if((s/n>0.45)&&(s/n<0.55)){
c = c+1;
s=0;
}
}
float a = c/1000;
printf("%f",a);
return 0;
}
Find attached the screen shots of different outputs with 3 different values of n. n=100, n=25, n=1I hope this will help!!!!!!
Thanks!!!
thumbs up ONLY for correct answer. thank you. Adapt the code and run it (in the...
Please answer and explain thank you. Question 1 What will be printed when the following code is executed? double x = 45678.259; System.out.printf("%,.2f", x); Group of answer choices 45678.259 0,045,678.26 45,678.26 45,678.3 Question 2 What will be printed when the following code is executed? double x = 45678.259; String output = String.format("%,.1f", x); System.out.println(output); Group of answer choices 45678.259 45,678.259 45,678.26 45,678.3 Question 3 What will be the value of ans after the following code has been executed? int ans=0;...
phase dtransformation diagram and heat treatment. Can you answer parts a b and c please. need it done in the next 30 mins 1: Using the phase transformation diagram below, describe heat treatment procedures to produce the following from eutectoid steel at 750°C 800 1400 А Eutectoid temperature 700 A 1200 P 600 1000 N 500 -- Temperature (°C) Temperature (°F) @ B 800 400 A 600 300 50% 400 200 100 104 10-1 105 1 103 10 102 Time...
Please answer the exercise 9.2. I have included the spectrums. Please review attached images and table to help answer questions. Match the compounds to their corresponding spectrums. Thank you very much! Match each spectrum in exercise 9.2 of your text (pages 449-450) to a compound on the right. Remember that you can use Table 9.2 on page 439 to solve these puzzles along with some of the reading. cycloheptene H2N 4-methylaniline CI p-dichlorobenzene ethynylbenzene 3-methylphenol odobenzene Choose... Exercise 9.2 spectrum...
PLEASE ANSWER QUICKLY!! I WILL THUMBS UP! Thank you so much in advance!! Neatly sketch the complete heat-pump cycle from Question 1 on a P-h diagram, showing clearly all six processes (1) - (2) - (3) - (4) - (5) - (6)-(1). If you have a printer available, you may print this PDF file of the R134a P-h diagram. Otherwise, draw a very neat scale copy of the P-h diagram shown below. You do not have to type any response...
NMR IR CAN YOU PLEASE ANSWER AS SOON AS POSSIBLE THANK YOU PLEASE EXPLAIN IT IN DETAIL THANK YOU Experimental Data Only report the IR absorptions that provide diagnosis for the major functional groups. Copies of your spectra will be included in your lab report with this information written on the spectra. However, the information should also be included in the body of the report in a text format similar to the example given below IR cm1: 1735 (C-o); MS:...
Assignment Predator / Prey Objectives Reading from and writing to text files Implementing mathematical formulas in C++ Implementing classes Using vectors Using command line arguments Modifying previously written code Tasks For this project, you will implement a simulation for predicting the future populations for a group of animals that we’ll call prey and their predators. Given the rate at which prey births exceed natural deaths, the rate of predation, the rate at which predator deaths exceeds births without a food...
please answer all thank you Homework - State Loading Advanced (Part 2) A solid round 20 mm diameter hur is based as shown below, where the lead iP XOAN, the downward tr adise.SSAN, the lig h the is M-20 Nm, and the true lead is T-30 Nm. This results in certain stresses in the bar the base al Points located at the top of the har d ew from (located ISO w from 4-y il Decated 270cw from located in...
This is the sequence 1,3,6,10,15 the pattern is addin 1 more than last time but what is the name for this patternThese are called the triangular numbers The sequence is 1 3=1+2 6=1+2+3 10=1+2+3+4 15=1+2+3+4+5 You can also observe this pattern x _________ x xx __________ x xx xxx __________ x xx xxx xxxx to see why they're called triangular numbers. I think the Pythagoreans (around 700 B.C.E.) were the ones who gave them this name. I do know the...
2. Gini Index Income Decile Income Share 0.05 0.1 0.15 0.2 0.25 0.35 un 0.45 1 a. Graph the Lorenz Curve for the table above. (If it helps to be more precise than the table: the Lorenz curve has a slope of 0.05 from 0 to 0.5 of the income distribution, a slope of 0.1 from 0.5 to 0.8 on the income distribution, and a slope of 0.2 from 0.8 to 1 on the income distribution) b. Calculate the Gini...
Problem 10-31 (Algo) Large-scale integrated (LSI) circuit chips are made in one department of an electronics firm. These chips are incorporated into analog devices that are then encased in epoxy. The yield is not particularly good for LSI manufacture, so the AQL specified by that department is 20% while the LTPD acceptable by the assembly department is 52%. Assume the company is willing to accept a consumer's risk of 10 percent and a producer's risk of 5 percent. Use Exhibit...