# module to genereate the random xvalues
import random
# to compute the square root value
import math
# method to read the number
def getNumber(msg):
print(msg)
x = input().strip()
if(x==""):
print("Missing input")
getNumber(msg)
else:
try:
x =
float(x)
except:
print("Invalid
input")
getNumber(msg)
return x
# method to compute the yvalues
def yOnEclipse(a,b,xValues):
xsqrd = [i**2 for i in xValues]
y=[]
y = [b*(math.sqrt(1-(x**2/a**2))) for x in
xValues]
return y
# method to verify the eclipse
def verifyPoints(a,b,xValues,yValues):
check =[]
check = [(x**2/a**2)+(y**2/b**2)==1 for x,y in
zip(xValues,yValues)]
return check
# main method
def main():
msg = "Enter the length of major Axis"
a = getNumber(msg)
msg = "Enter the length of minor axis"
b= getNumber(msg)
msg = "Enter number of point along major axis"
n = getNumber(msg)
# uniform() method to generate the random floating
point numbers in the given range
xValues =[round(random.uniform(0,a),2) for i in
range(int(n))]
yValues = yOnEclipse(a,b,xValues)
check = verifyPoints(a,b,xValues,yValues)
# ouput the values
print("X","Y","OnEclipse",sep="\t")
for x,y,c in zip(xValues,yValues,check):
print(x,y,c,sep="\t")
# called when executed directly without importing module
if __name__ == '__main__':
main()
please there are some specific instructions on the question so i would greatly appreciate if they...
Please help code in c++ and use the answers you get from question 1
and 2 into the 3rd answer! Question 1 is first, question 2 is in
the middle, question 3 is last
Input Array (10 pts) te a function only (no main) that takes an array of doubles as a parameter as well as another integer rray. Create a for loop that asks the user to input any real number between-100 and r each element of the array....
I should use the array and loop to create a java program
according to the instruction, but I have no idea how to do
it.
Introduction This lab assignment continues to give you practice using loops, particularly loops with variable termination conditions, and it also provides you an opportunity to use one-dimensional arrays. Recall that an array is used to store a collection of data. The data can be values of Java primitive data types or else objects (for instance,...
Programming language C Please go through this carefully. Needs function void add(int *a1, int n, int *a2) Write a program addition.c that reads in an array (a1) of numbers, and creates a new array (a2) of numbers such that the first and last numbers of a1 are added and stored as the first number, the second and second-to-last numbers are added and stored as the second number, and so on. You need to check for even and odd length of...
Write a C program convert.c that converts each number in an array by the sum of that number plus 6 modulus 10. A sample input/output: Enter the length of the array: 5 Enter the elements of the array: 3 928 4 14 77 Output: 9 4 0 0 3 The program should include the following function: void convert(int *a1, int n, int *a2) The function converts every element in array a1 of length n to an output array a2. The...
Thank you!
/*Lab 8 : Practicing functions and arrays
Purpose:
*/
#include<iostream>
#include<fstream>
using namespace std;
int read_function(int array[], int, int);
int main()
{
int array[300], numba;
read_function(array[300]);
cout << "Enter a whole number between 2-20: " <<
endl;
cin >> numba;
read_function(numba);
return 0;
}
int read_funtion (int arr[300], int num, int Values)
{
int sum=0;
ifstream array_file;
array_file.open("Lab8.dat");
for(int i=0; i < 300; i++)
{
array_file >> arr[i];
cout << arr[i];
sum += i;
}
cout << sum;...
In this lab, you will create a program to help travelers book flights and hotel stays that will behave like an online booking website. The description of the flights and hotel stays will be stored in two separate String arrays. In addition, two separate arrays of type double will be used to store the prices corresponding to each description. You will create the arrays and populate them with data at the beginning of your program. This is how the arrays...
C++ please Possible algorithms – (1) use and modify the algorithm from program 2 if possible; (2) use unique value array; (3) use flag array (flags used to avoid counting a number more than 1 time); (4) compute frequency distribution (use unique and count arrays); (5) use count array to store the frequency of a number. No global variable are permitted in this assignment. Do not change the code provided only write the missing code. Write the missing C++ statements...
AND logic gate simulation in Python: Please fix the code below so that it efficiently performs the operation of the AND logic gate in Python. (Leave comments in the edited code about what you changed) #if both values are 1, return true, other wise return false print ("Logic Gate Simulation: AND gate") def AND(x, y): if x == True and y == True: return True else: return False def main(): x = bool(input("Please...
Please follow the instructions below to create a code. The instructions are broken down into a few steps. Create the following functions along with a driver for each one confirming it works. The driver needs to test the function with at least 5 different inputs, although more is always better. Be sure to use the function display_startup_banner( ) in all of your drivers. Please create separate files for each code. That is, if you're creating a function called learning_online_is_a_trip( )...
public static double[] getVolumes(double[] base, double[] height, double[] length) Write a Java program called TriangularPrisms which does the following: In the main method: Use a for loop which repeats three times. Within the loop, a. prompt the user to enter the base of the triangular prism and store the value in a double array called base b. prompt the user to enter the corresponding height and store the value in a double array called height c. prompt the user to...