Want Program Thing One Main Function Instead One Main Function Plus One User Defined Funct Q43838842
we want the program to do the same thing, but with not onemain() function, but instead one main() function PLUS one userdefined function called computeConeVolume that contains thecalculation. In other words, remove the one line calculation,replace it with a function call, then write and add the functionbelow main with the calculation, surrounded any other syntax youneed to complete it. in C++
– I need some help, thanks!
#include <iostream>
using namespace std;
int main()
{
//Declare variables and constants
double coneRadius = 0.0;
double coneHeight = 0.0;
const double PI = 3.14;
double coneVolume = 0.0;
//Prompt the user for inputs
cout << “Enter the radius of the cone:”;
cin >> coneRadius;
cout << “Enter the height of the cone:”;
cin >> coneHeight;
//Do the calculation
coneVolume = 0.33 * PI * coneRadius * coneRadius* coneHeight;
//Display the result
cout << “The volume of your cone is: “<< coneVolume << endl;
system(“pause”);
return 0;
} //end of main
Expert Answer
Answer to we want the program to do the same thing, but with not one main() function, but instead one main() function PLUS one use…
Wanted 64 Mb Direct Mapped L2 Cache Block Size 8 Words Show Design Different Fields L2 Cac Q43796168
If you wanted a 64 MB direct mapped L2 cache with block size of8 words. show the design of the different fields in L2 cache.Explain how CPU’s 48 bits address will be checked to determine ifit is in the L2 cache assume a page size of 256KB
Expert Answer
Answer to If you wanted a 64 MB direct mapped L2 cache with block size of 8 words. show the design of the different fields in L2 c…
Wanted Advice Code M Getting Compiling Errors Q43870521
Just wanted some advice on my code, I’m gettingcompiling errors.
Java 7 Autocomplete Ready O 1 > import java.io.*;. 10 class Result { * Complete the ‘bestPros’ function below. * The function is expected to return an INTEGER_ARRAY. * The function accepts following parameters: * 1. 2D_INTEGER_ARRAY pros * 2. INTEGER K * public static List<Integer> bestPros(List<List<Integer>> pros, int k) { // Write your code here Integer[][] bestpros; When a Thumbtack user creates a new project, we recommend the best Pros for the job based on a metric called the Pro Matching Score (PMS). This score is calculated using two factors: the distance the Pro would have to travel to the job, and the Pro’s average rating. More specifically, PMS is defined as (max_distance – distance) * rating, where max_distanceis the maximal distance that any Pro has from the given user. Naturally, a higher PMS means the Pro is a better match for the project. You have an array that represents the Pros who are available to complete a new project for a user, where each element of the array is a distance, rating) tuple. distance is the distance of the Pro from the user’s project location, and rating is their overall rating. Given the array pros for a specific project, determine the kPros who are best suited to complete it, based on their Pro Matching Score. Return a list of the indices (0-based) at which these Pros appeared in the original pros array, sorted by their PMS score. In the case of a PMS tie, the Pro with the smaller index goes first. Example For pros = [[5, 4], [4, 3], [6, 5], [3, 5]] and k = 2, the output should be bestPros(pros, k) = [3, 1]. The PMSs of the Pros are: Integer[] bestKpros; //Find max value in pros array int max = Integer.MIN_VALUE; for (int i = 0; i < pros.size(); i++) { for(int j = 0; j <pros.get(i).size(); j++){ if (pros.get(i).get(j) > max) { max = pros.get(i).get(i); for (int i = 0; i < pros.size(); i++) { int pro = (max – pros.get(i).get() * pros.get(i).get(1)); ArrayList<Integer> temp = new ArrayList<Integer>(); temp.add(pro); temp.add(i); bestpros.add(temp); . oth pro: (6 – 5) * 4 = 4; Arrays.sort (bestpros, Collections. reverseOrder()); • 1st pro: (6 – 4) + 3 = 6; • 2nd pro: (6 – 6) * 5 = 0; for(int i = 0; i < bestpros. length && i <k; i++) { bestKpros.add(bestproslili. • 3rd pro: (6 – 3) * 5 = 15. Arrays.sort (bestKpros); The output is [3, 1] since the Pros at indices 1 and 3 have the highest scores. Since pro [3] has a higher PMS than pro[1], index 3 appears first in the array return bestKpros; } Show transcribed image text Java 7 Autocomplete Ready O 1 > import java.io.*;. 10 class Result { * Complete the ‘bestPros’ function below. * The function is expected to return an INTEGER_ARRAY. * The function accepts following parameters: * 1. 2D_INTEGER_ARRAY pros * 2. INTEGER K * public static List bestPros(List pros, int k) { // Write your code here Integer[][] bestpros; When a Thumbtack user creates a new project, we recommend the best Pros for the job based on a metric called the Pro Matching Score (PMS). This score is calculated using two factors: the distance the Pro would have to travel to the job, and the Pro’s average rating. More specifically, PMS is defined as (max_distance – distance) * rating, where max_distanceis the maximal distance that any Pro has from the given user. Naturally, a higher PMS means the Pro is a better match for the project. You have an array that represents the Pros who are available to complete a new project for a user, where each element of the array is a distance, rating) tuple. distance is the distance of the Pro from the user’s project location, and rating is their overall rating. Given the array pros for a specific project, determine the kPros who are best suited to complete it, based on their Pro Matching Score. Return a list of the indices (0-based) at which these Pros appeared in the original pros array, sorted by their PMS score. In the case of a PMS tie, the Pro with the smaller index goes first. Example For pros = [[5, 4], [4, 3], [6, 5], [3, 5]] and k = 2, the output should be bestPros(pros, k) = [3, 1]. The PMSs of the Pros are: Integer[] bestKpros; //Find max value in pros array int max = Integer.MIN_VALUE; for (int i = 0; i
Expert Answer
Answer to Just wanted some advice on my code, I’m getting compiling errors….
Wanted Make Changes Email Address Policy Could Perform Following Tasks Choose Apply Click Q43873248
If you wanted to make changes to the email address policy, youcould perform which of the following tasks? (Choose all thatapply.)
a. Click the Apply To link on the next tab to select the scopeof the policy.
b. Use the EMS cmdlet Set-EmailAddressPolicy
c. Define an accepted domain.
d. Use the EMS cmdlet Update-EmailAddressPolicy
Expert Answer
Answer to If you wanted to make changes to the email address policy, you could perform which of the following tasks? (Choose all t…
Wanted Securely Transfer Files Local Machine Web Server File Transfer Protocol Could Use 1 Q43841607
If you wanted to securely transfer files from your local machineto a web server, what file transfer protocol could you use?
1. FTP
2. TFTP
3.SFTP
4.NTP
Expert Answer
Answer to If you wanted to securely transfer files from your local machine to a web server, what file transfer protocol could you…
Watching World S Strongest Man Competition Television Competitors Perform Amazing Feats St Q43893961
you have been watching the World’s Strongest Man competition ontelevision. The competitors perform amazing feats of strength suchas pulling trucks along a course, flipping huge tires, liftinglarge objects. You can tell the items are quite heavy but theBritish announcer keeps referring to the weights in stones. AfterReading Introduction to Computers and Problem Solving inyour textbook and watching the Video, An Introduction toComputers and Problem Solving, create a Sequence Flow chartfor a program that will read in weight in stones, converts weightin stones to the equivalent weight in pounds where 1 stone is 14pounds, round up to the next whole number, and display thepounds.
Expert Answer
Answer to you have been watching the World’s Strongest Man competition on television. The competitors perform amazing feats of str…
Waterfall Spiral Vee Cycle Model Model Model Model Functions Performed Relationship Design Q43858664
Waterfall Spiral Vee Cycle Model Model Model Model Functions Performed Relationship of design to Integration Time Sequence of Functions Outputs Produced Interaction with Stakeholders What is most different from the other models Types of Systems most suited for Show transcribed image text Waterfall Spiral Vee Cycle Model Model Model Model Functions Performed Relationship of design to Integration Time Sequence of Functions Outputs Produced Interaction with Stakeholders What is most different from the other models Types of Systems most suited for
Expert Answer
Answer to Waterfall Spiral Vee Cycle Model Model Model Model Functions Performed Relationship of design to Integration Time Sequen…
Way Add Try Catch Code Import Javatextnumberformat Import Javautilscanner Public Class Fut Q43904105
Is there any way to add try andcatch into this code?
import java.text.NumberFormat;
import java.util.Scanner;
public class FutureValueApp {
public static void main(String[] args) {
System.out.println(“Welcome to the Future Value Calculatorn”);
Scanner sc = new Scanner(System.in);
String choice = “y”;
System.out.println(“DATA ENTRY”);
while (choice.equalsIgnoreCase(“y”)) {
/////get user input
double monthlyInvestment = getDoubleWithinRange(sc,
“Enter monthly investment: “, 0, 1000);
double interestRate = getDoubleWithinRange(sc,
“Enter yearly interest rate: “, 0, 30);
int years = getIntWithinRange(sc,
“Enter number of years: “, 0, 100);
System.out.println();
//////future value calculation
double monthlyInterestRate = interestRate / 12 / 100;
int months = years * 12;
double futureValue = calculateFutureValue(
monthlyInvestment, monthlyInterestRate, months);
//////print results
System.out.println(“FORMATTED RESULTS”);
printFormattedResults(monthlyInvestment, interestRate,
years, futureValue);
////// see if user wants to continue
choice = askToContinue(sc);
}
}
public static double getDoubleWithinRange(Scanner sc, Stringprompt,
double min, double max) {
double d = 0;
boolean isValid = false;
while (isValid == false) {
d = getDouble(sc, prompt);
if (d <= min) {
System.out.println(
“Error! Number must be greater than ” + min + “.”);
} else if (d >= max) {
System.out.println(
“Error! Number must be less than ” + max + “.”);
} else {
isValid = true;
}
}
return d;
}
public static double getDouble(Scanner sc, String prompt){
double d = 0;
boolean isValid = false;
while (isValid == false) {
System.out.print(prompt);
if (sc.hasNextDouble()) {
d = sc.nextDouble();
isValid = true;
} else {
System.out.println(“Error! Invalid number. Try again.”);
}
sc.nextLine(); //////discard other data entered on line
}
return d;
}
public static int getIntWithinRange(Scanner sc, Stringprompt,
int min, int max) {
int i = 0;
boolean isValid = false;
while (isValid == false) {
i = getInt(sc, prompt);
if (i <= min) {
System.out.println(
“Error! Number must be greater than ” + min + “.”);
} else if (i >= max) {
System.out.println(
“Error! Number must be less than ” + max + “.”);
} else {
isValid = true;
}
}
return i;
}
public static int getInt(Scanner sc, String prompt) {
int i = 0;
boolean isValid = false;
while (isValid == false) {
System.out.print(prompt);
if (sc.hasNextInt()) {
i = sc.nextInt();
isValid = true;
} else {
System.out.println(“Error! Invalid integer. Try again.”);
}
sc.nextLine(); //////discard other data entered on line
}
return i;
}
public static double calculateFutureValue(doublemonthlyInvestment,
double monthlyInterestRate, int months) {
double futureValue = 0;
for (int i = 1; i <= months; i++) {
futureValue = (futureValue + monthlyInvestment) *
(1 + monthlyInterestRate);
}
return futureValue;
}
public static String askToContinue(Scanner sc) {
System.out.print(“Continue? (y/n): “);
String choice = sc.next();
sc.nextLine(); ////// discard other data entered on line
System.out.println();
return choice;
}
private static void printFormattedResults(doublemonthlyInvestment,
double interestRate, int years, double futureValue) {
///// get percent and currency formatters
NumberFormat p = NumberFormat.getPercentInstance();
NumberFormat c = NumberFormat.getCurrencyInstance();
p.setMinimumFractionDigits(1);
///// format result as single string
String results
= “Monthly investment: ” + c.format(monthlyInvestment) + “n”
+ “Yearly interest rate: ” + p.format(interestRate / 100) +”n”
+ “Number of years: ” + years + “n”
+ “Future value: ” + c.format(futureValue) + “n”;
///// print results
System.out.println(results);
}
}
Expert Answer
Answer to Is there any way to add try and catch into this code? import java.text.NumberFormat; import java.util.Scanner; public cl…
Way Compute Square Root Positive Real Number Say X Make Wild Guess Square Root Number G Ch Q43888223
Here is a way to compute the square root of a positive realnumber say x. We make a wild guess that the square root is somenumber g. Then we check if g2 is close to x. If it is we return gas our answer; if not we refine our guess using the formula
g′ = (g + x/g)/2.0
where g′ is the new guess. We keep repeating until we are closeenough. Write an OCaml program to implement this idea. Since we areworking with floating point numbers we cannot check for equality;we need to check if the numbers are close enough. I have written afunction called close
1Unless you are extending the factorial to non-integer valuesthrough the Gamma function.
for you as well as a function called square. In OCaml floatingpoint operations need special symbols: you need to put a dot afterthe operation. Thus you need to write, for example, 2.0+.3.0. Allthe basic arithmetic operations have dotted versions: +., ∗., /.and must be used with floating point numbers. You cannot writeexpressions like 2 + .3.5 or 2.0 + 3.0. We will not test yourprogram on negative inputs so we are not requiring you to deal withthe possibility that you may get a negative answer. There are ofcourse built-in functions to compute square roots. We have writtenthe tester program to check if you used this; you will get a zeroif you use a built-in function for square roots.
(* Q2 TODO: Write your own tests for the mysqrt function.
You should NOT test cases for n < 0.
*)
let mysqrt_tests = [
(* Your test cases go here. *)
]
(* Q2 TODO: Implement mysqrt. *)
let mysqrt (x:float) = raise NotImplemented
Expert Answer
Answer to Here is a way to compute the square root of a positive real number say x. We make a wild guess that the square root is s…
Way Use Switches Lan Networks Impact Overall Network Throughput Q43800584
In what way can the use of switches in LAN networks impactoverall network throughput?
Expert Answer
Answer to In what way can the use of switches in LAN networks impact overall network throughput?…