Write a method called priceIsRight that mimics the guessing rules from the game show The Price is Right. The method accepts as parameters an array of integers representing the contestants’ bids and an integer representing a correct price. The method returns the element in the bids array that is closets in value to the correct price without being larger than that price. For example, is an array called bids stores the value {200, 300, 250, 1, 950, 40} the call of priceIsRight(bids, 280) should return 250, since 250 is the bid closets to 280 without going over 280. If all bids are larger than the correct price, your method should return -1.

Answers

Answer 1

Answer:

Here is the method :

public static int priceIsRight(int[] bids, int correctPrice) { /*definition of method priceIsRight that accepts as parameters an array of integers representing the contestants’ bids and an integer representing a correct price */

   int nearest = -1;  //initializes the closest value to -1

   for(int i = 0; i < bids.length; i++) { //iterates through the bids array until length of the bids array reaches

       if(bids[i] <= correctPrice && bids[i] > nearest) //checks the element of the bids array that is closest (nearest) in value to the correct price without being larger than that price

           nearest = bids[i];    }    //sets that element of bids at index i which is closest to correcPrice to nearest variable

   return nearest; } //returns the element in the bids array that is nearest in value to the correctPrice

Explanation:

To check the working of the above method you can call this function in main()

public static void main(String[] args) { //start of main function    

    int[] bids = {200, 300, 250, 1, 950, 40}; //declares and array and assigns elements to it

    System.out.println(priceIsRight(bids,280)); } } //calls priceIsRight method by passing the bids array and 280 as correct price

The method works as follows:

Suppose we have an array called bids with elements {200, 300, 250, 1, 950, 40}

nearest = -1

correctPrice = 280

The for loop for(int i = 0; i < bids.length; i++) works as follows:

At first iteration:

i = 0

i< bids.length is true because i=0 and bids.length = 6

so program control moves inside the loop body:

if(bids[i] <= correctPrice && bids[i] > nearest) this if statement becomes:

if(bids[0] <= correctPrice && bids[0] > nearest)

This if condition has two parts and it uses && AND logical operator between them so both of the conditions should hold  for the if condition to evaluate to true.

bids[0] <= correctPrice

the element at 0-th index of bids array is 200 and correctPrice= 280 So 200 is less than 280. This part of if condition is true.

bids[0] > nearest

the element at 0-th index of bids array is 200 and nearest = -1. So 200 is greater than -1. Hence this part of if condition is also true.

Hence both the parts of the if statement are true and if condition evaluates to true. So the program control moves to the statement:

nearest = bids[i];

This becomes:

nearest = bids[0]

nearest = 200

At second iteration:

i = 1

i< bids.length is true as i=1 and bids.length = 6

so program control moves inside the loop body:

if(bids[1] <= correctPrice && bids[1] > nearest) this if statement becomes:

if(bids[1] <= correctPrice && bids[1] > nearest)

bids[1] <= correctPrice

the element at 1st index of bids array is 300 and correctPrice= 280 So 300 is greater than 280. This part of if condition is false.

So the if condition evaluates to false. So the value of nearest remains the same.

nearest = 200

At third iteration:

i = 2

i< bids.length is true as i=2 and bids.length = 6

if statement becomes:

if(bids[2] <= correctPrice && bids[2] > nearest)

bids[0] <= correctPrice

the element at 2nd index of bids array is 250 and correctPrice= 280 So 250 is less than 280. This part of if condition is true.

bids[2] > nearest

the element at 2nd index of bids array is 250 and nearest = 200. So 250 is greater than 200. Hence this part of if condition is also true.

Hence  if condition evaluates to true. So the program control moves to the statement:

nearest = bids[i];

nearest = bids[2]

nearest = 250

At fourth iteration:

i = 3

i< bids.length is true because i=1 and bids.length = 6

if statement becomes:

if(bids[3] <= correctPrice && bids[1] > nearest)

bids[3] <= correctPrice

the element at third index of bids array is 1 and correctPrice= 280 So 1 is less than 280. This part of if condition is true.

bids[3] > nearest

the element at 3rd index of bids array is 1 and nearest = 250. So 1 is less than 200. Hence this part of if condition is false. So value of nearest remains the same

nearest = 250

At fifth iteration:

i = 4

i< bids.length is true because i=4 and bids.length = 6

if statement becomes:

if(bids[4] <= correctPrice && bids[4] > nearest)

bids[4] <= correctPrice

the element at 4th index of bids array is 950 and correctPrice= 280 So 950 is greater than 280. This part of if condition is false.

So the if condition evaluates to false. Hence

nearest = 250

At sixth iteration:

i = 5

i< bids.length is true because i=5 and bids.length = 6

so program control moves inside the loop body:

if statement becomes:

if(bids[5] <= correctPrice && bids[5] > nearest)

bids[5] <= correctPrice

the element at fifth index of bids array is 40 and correctPrice= 280 So 40 is less than 280. This part of if condition is true.

bids[5] > nearest

the element at 5th index of bids array is 40 and nearest = 250. So 40 is less than 250. Hence this part of if condition is false. So value of nearest remains the same

nearest = 250

Now the loop breaks at i = 6 because i < bids.length condition evaluates to false.

The statement return nearest; executes now. This returns the value of nearest. So this method returns 250.

Write A Method Called PriceIsRight That Mimics The Guessing Rules From The Game Show The Price Is Right.

Related Questions

(5 points) Create a user-defined data structure (i.e., struct) called Point that represents a two-dimensional Cartesian coordinate (x, y). The member variables of this struct will be just x and y, which are both floating-point values. (5 points) Define a function called calculateDistance that takes two parameters, each of type Point* (i.e., pointer to Point) and returns the distance between the two given points. As you may recall, the formula for calculating the distance between two points, say p1(x1, y1) and p2(x2, y2) is:

Answers

Answer:

Here is the C++ program:

#include<iostream>  //to use input output functions

#include <math.h>  //to use sqrt and pow function

#include<iomanip>  //to use setprecision

using namespace std;   //to identify objects cin cout

struct Point  {  // structure name

float x,y;  // member variables

};  

float calculateDistance (Point a, Point b)  {  //function that that takes two parameters of type Point

float distance;  //stores the distance between two points

distance=sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));  //formula to compute distance between two points

return distance;  }  //returns the computed distance

int main()  {  //start of main function

Point p1,p2;  //creates objects of Point

cout<<"Enter point 1 coordinates: "<<endl;  //prompts user to enter the value for coordinates of first point

cin>>p1.x;  //reads input value of x coordinate of point 1 (p1)

cin>>p1.y;  //reads y coordinate of point 1 (p1)

cout<<"Enter point 2 coordinates: "<<endl;  //prompts user to enter the value for coordinates of second point

cin>>p2.x;  //reads input value of x coordinate of point 2 (p2)

cin>>p2.y;  //reads y coordinate of point 2 (p2)

cout<<"The distance between two points is "<<fixed<<setprecision(2)<<calculateDistance(p1,p2);} //calls function by passing p1 and p2 to compute the distance between p1 and p2 and display the result (distance) up to 2 decimal places

Explanation:

The program has a structure named Point that represents a two-dimensional Cartesian coordinate (x, y). The member variables of this struct are x and y, which are both floating-point values. A function called calculateDistance takes two parameters, a and b of type Pointer and returns the distance between the two given points using formula:

[tex]\sqrt{(x_{2}-x_{1} )^{2} +(y_{2}-y_{1} )^{2} }[/tex]

It uses pow function to compute the power of 2 and sqrt function to compute the square root.

Then in main() method the program prompts the user to enter coordinates for two points and calls calculateDistance method to compute the distance between two points and display the result up to 2 decimal places using setprecision(2).

The program along with the output is attached in a screenshot.

Write a function named replaceSubstring. The function should accept three string object arguments entered by the user. We want to look at the first string, and every time we say the second string, we want to replace it with the third. For example, suppose the three arguments have the following values: 1: "the dog jumped over the fence" 2: "the" 3: "that" With these three arguments, the function would return a string object with the value "that dog jumped over that fence". Demonstrate the function in a complete program. That means you have to write the main that uses this.

Answers

Answer:

public class Main{

public static void main(String[] args) {

 System.out.println(replaceSubstring("the dog jumped over the fence", "the", "that"));

}

public static String replaceSubstring(String s1, String s2, String s3){

    return s1.replace(s2, s3);

}

}

Explanation:

*The code is in Java.

Create function called replaceSubstring that takes three parameters s1, s2, and s3

Use the replace function to replace the s2 with s3 in s1, then return the new string

In the main:

Call the replaceSubstring function with the given strings and print the result

Create a program that will read in a Salesperson name, employment status (1=Full-time AND 2=Part-time) and the sales amount.
In the Output, display the salesperson name along with the commission amount earned. The commission rate for full-time is 4% while for part-time is 2%.
Lastly, your program must also display the text “You have exceeded the sales quota!” if the following conditions are met:
Full-time and sales is over 1000
Part-time and sales is over 500
Use the Console for the Input and Output.

Answers

Answer:

Written using Python

name = input("Name: ")

print("1 for Full time and 2 for Part time")

status = int(input("Status: "))

sales = float(input("Sales Amount: "))

if status == 1:

     commission = 0.04 * sales

else if status == 2:

     commission = 0.02 * sales

print(name)

print(commission)

if status == 1 and sales>1000:

     print("You have exceeded the sales quota!")

if status == 2 and sales>500:

     print("You have exceeded the sales quota!")

Explanation:

I've added the full source code as an attachment where I used comments to explain some lines

What is the default file extension for all Word documents?

Question 8 options:

.txts


.word


.docs


.docx

Answers

Answer:

The correct answer is docx

.docx is the answer

In which of these places might you be most likely to find a peer-to-peer network? *

In a large office building
On the Internet
In a home
In a hospital

Answers

Answer:

(b) On the Internet

Explanation:

Peer-to-Peer or P2P network is a networking technology that allows several network devices to share resources and exchange resources and directly communicate with each other.

In P2P network , all the computers and devices are part of the network are called as peer.

Peer-to-Peer is used to share processing power, network bandwidth or disk storage space. But most common use of peer-to-peer is sharing of files on internet.

Answer:

in a home is the correct answer

Good afternoon guys !!!

For all those Computer science smart people i am calling you !!!

i need you to answer this question asap and as best as you can

BE creative

thank you so much

With your partner, think of a new app idea. What inputs does it need? What outputs? What types of processing does it use to change the input to output?




App idea



Inputs



Outputs



Types of processing



How processing turns helps turn input to output

Answers

Answer:

your answer is

outputs

Question 4 (Multiple Choice Worth 5 points)
(03.04 MC)
Which function will add a name to a list of baseball players in Python?

A append()
B main
C print()
D sort(

Answers

Answer:

A. append()

Explanation:

I don't know python fully but i do know what stuff means

Print: display text

Main: basically the roots of the entire code

Sort: it's in the freaking name

so crossing out 3 of the 4 its safe to assume its append.

Answer:

A) The function that will add a name to a list of base ball players in python is append.

Explanation:

(The Location class) Design a class named Location for locating a maximal value and its location in a two-dimensional array. The class contains public data fields row, column, and maxValue that store the maximal value and its indices in a two dimensional array with row and column as int type and maxValue as double type.Write the following method that returns the location of the largest element in a two-dimensional array.public static int[] locateLargest(double[][] a)The return value is a one-dimensional array that contains two elements. These two elements indicate the row and column indices of the largest element in the two dimensional array. Write a test program that prompts the user to enter a two-dimensional array and displays the location of the largest element in the array. Here is a sample run:Enter the number of rows and columns of the array: 3 4Enter the array:23.5 35 2 104.5 3 45 3.535 44 5.5 9.6The location of the largest element is at (1, 2)

Answers

Answer:

Here is the Location class:

public class Location {   //class name

   public int row;  // public data field to hold the value of no. of rows

   public int column;  // public data field to hold the value of no. of columns

   public double maxValue;   //public data field to hold the maximum value

   public Location(int row, int column, double maxValue) { //parameterized constructor of Location class

//this keyword is used to refer to a current instance variable and used to avoid naming conflicts between attributes and parameters with the same name

       this.row = row;  

       this.column = column;  

       this.maxValue = maxValue;     }  

   public static Location locateLargest(double[][] a) {   //method that takes a 2 dimensional array a as argument and returns the location of the largest element

       int row = 0;  //initializes row to 0

       int column = 0;  //initializes column to 0

       double maxValue = a[row][column];   //stores largest element

       for (int i = 0; i < a.length; i++) {  //iterates through rows of a[] array

           for (int j = 0; j < a[i].length; j++) {  //iterates through columns of array

               if (maxValue < a[i][j]) {  //if the maxValue is less than the element of 2 dimensional array at ith row and jth column

                   maxValue = a[i][j];  //then set that element to maxValue

                   row = i;  // i is set to traverse through rows

                   column = j;   }             }         }  // i is set to move through columns

       return new Location(row,column,maxValue);     }  } //calls constructor of class by passing row, column and maxValue as argument

Explanation:

Here is the Main class with a main() function to  test program  

import java.util.Scanner;   //to accept input from user

public class Main {   //class name

   public static void main(String[] args) {   //start of main function

       Scanner scan = new Scanner(System.in);  //creates Scanner class object to scan the input from user

 System.out.print("Enter the number of rows and columns in the array: ");  //prompt for user

       int row = scan.nextInt();  // reads value of row from user

       int column = scan.nextInt();  //reads input value of column

       double[][] array = new double[row][column];   //declares a 2 dimensional array named array

       System.out.println("Enter the array:");  //prompts to enter array elements

       for (int i = 0; i < array.length; i++) {  //iterates through the rows of array until the size of array is reaced

           for (int j = 0; j < array[i].length; j++) {  //iterates through the columns of array

               array[i][j] = scan.nextDouble();    }    }   //reads each element at i-th row and j-th column

       Location location = Location.locateLargest(array);  //calls locateLargest method by passing array to it in order to locate the largest element in the array

System.out.println("The largest element in a two-dimensional array is: " + location.maxValue);  //displays the largest element of array

       System.out.println("The location of the largest element is at (" + location.row + ", " + location.column + ")");       }    } //displays the location of the largest element in the two dimensional array

Suppose the user enters 2 rows and 2 columns. The elements are:

1         5.5

4.5      3

The program works as follows:

for (int i = 0; i < array.length; i++) this outer loop iterates through rows

i = 0

inner loop for (int j = 0; j < array[i].length; j++) iterates through columns

array[i][j] = scan.nextDouble(); reads the element at position i-th row and j-th column. This becomes:

array[0][0] = scan.nextDouble();

so element at 0th row and 0th column is 1

Location location = Location.locateLargest(array); now this calls the method which works as follows:

double maxValue = a[row][column]; this becomes:

double maxValue = a[0][0];

so maxValue = 1

for (int i = 0; i < a.length; i++) this loop in method iterates through rows and  for (int j = 0; j < a[i].length; j++) this iterates through columns of array

if (maxValue < a[i][j]) this becomes:

if (maxValue < a[0][0])

As we know that maxValue = 1 so this if condition is true.

                   maxValue = a[i][j];  this becomes:

             maxValue = a[0][0];  

maxValue = 1

Now set row = 0 and column = 0

Now the inner loop value of j is incremented to 1. So j = 1

At next iteration array[0][1] is checked. The element at this position is 5.5

if (maxValue < a[i][j]) is true because 1<5.5 so now value of maxValue becomes:

maxValue = 5.5

and

i = 0  j = 1

This way at each iteration of inner loop the columns are traversed and at each iteration of outer loop rows are traversed.

At next iteration element at array[1][0] is checked which is 4.5. This is not greater than maxValue so maxValue remains 5.5

At next iteration element at array[1][1] is checked which is 3. This is not greater than maxValue so maxValue remains 5.5 .

After both the loops end the statement:

return new Location(row,column,maxValue);

returns row , column and maxValue

where row = 0  column = 1 and maxValue = 5.5

So the output is:

The largest element in a two-dimensional array is: 5.5

The location of the largest element is at (0,1)

In this exercise we have to write a JAVA code requested in the statement, like this:

find the code in the attached image

We can write the code in a simple way like this below:

import java.util.Scanner;

public class Main {  

  public static void main(String[] args) {  

      Scanner scan = new Scanner(System.in);

System.out.print("Enter the number of rows and columns in the array: ");  

      int row = scan.nextInt();

      int column = scan.nextInt();

      double[][] array = new double[row][column];  

      System.out.println("Enter the array:");  

      for (int i = 0; i < array.length; i++) {

          for (int j = 0; j < array[i].length; j++) {  

              array[i][j] = scan.nextDouble();    }    }  

      Location location = Location.locateLargest(array);  

System.out.println("The largest element in a two-dimensional array is: " + location.maxValue);  

      System.out.println("The location of the largest element is at (" + location.row + ", " + location.column + ")");       }    }

See more about JAVA at brainly.com/question/2266606

Which of the following could NOT be represented by a boolean variable?

Whether a moving elevator is moving up or down

Whether a traffic light is green, yellow or red

Whether a store is open or closed

Whether a light-bulb is on or off

Answers

Answer:

Whether a traffic light is green, yellow or red

Explanation:

Boolean variables are variables that can either take one out of two options at any given instance.

Analyzing the given options

1. Elevator:

Possible Directions = Up or Down; That's two possible values

But it can only move in one direction at a given instance.

This can be represented using Boolean

2. Traffic Light:

Possible Lights = Green, Yellow or Red

That's three options.

This can be represented using Boolean

The last two options can be represented using Boolean because they have just two possible values

Hence, option (B) answers the question

Dividing a hard drive into multiple sections is known as partitioning

Answers

Answer:

Partitioning

Explanation:

Classifying a hard drive into multiple sections is called as Partitioning.Here each regions can be managed separately.Partitioning allows the use of different file systems to be installed for different kinds of files.Partitioning can also make back up easier

Assignment 2: Room area

Answers

Answer:

a = float(input("Enter Side A: "))

b = float(input("Enter Side B: "))

c = float(input("Enter Side C: "))

d = float(input("Enter Side D: "))

e = float(input("Enter Side E: "))

area1 = 1.0* a * b

area2 = (a - c) * (d - e -b)

area3 = 0.5 * (a - c) * e

print ("Room Area: " + str(area1 + area2 + area3))

Explanation:

happy to help ^3^

Answer:

a = float(input("Enter side A: "))

b = float(input("Enter side B: "))

c = float(input("Enter side C: "))

d = float(input("Enter side D: "))

e = float(input("Enter side E: "))

area1 = (b)*(c)

area2 = (d-e)*(a-c)

area3 = (0.5)*(a-c) *(e)

print("Room Area: " + str(area1 + area2 + area3))

Explanation:

i got a 100, i hope it helps

What is the primary purpose of a namespace?

Answers

Answer:

A namespace ensures that all of a given set of objects have unique names so that they can be easily identified.

Explanation:

Answer:

A namespace ensures that all of a given set of objects have unique names so that they can be easily identified.

Explanation:

Question 1 Multiple Choice Worth 5 points)
(03.01 MC)
Cheri needs to write a small program that interacts with the user. What step will allow her to do this?
Assigning a value to a variable
Giving step-by-step directions
Including an input statement
Incorporating engaging content

Answers

Answer:

c

Explanation:

Answer:

c

Explanation:

took the test

Write a program that will input the names, ages and weights of three siblings and display the lightest followed by the youngest of the siblings. Do the above assignment without using an array of objects. Implementation Create a project asSibling. In the above project, create a class Sibling not containing the main method. In the above project, create a class TestSibling containing the main method.

Answers

Answer:

Here is the JAVA program:

Sibling.java class:

import java.util.Scanner;  //to accept input from user

public class Sibling {  //class name

//private data members of class

   private String name;  // String type variable to hold the name of sibling

   private int age;  // int type variable to hold the age of sibling

   private int weight;  // int type variable to hold the weight of sibling

   public Sibling() {}     //constructor of class Sibling

   public Sibling (String n, int a, int w)  {  //parameterized constructor

       name = n;  // refers to name field

       age = a;  // refers to age field

       weight = w;    }   // refers to weight field

   public String getName ()    {   //accessor method to get the current name of sibling

       return name;    }   //returns the name field of the sibling

   public int getAge ()    {   //accessor method to get the current age of sibling

       return age;    }   //returns the age field of the sibling

   public int getWeight (){ //accessor method to get the current weight of sibling

    return weight;    } //returns the weight field of the sibling

   public void getInput() {    //to take input name,age and weight from user

 Scanner input = new Scanner(System.in);  //Scanner class object

 System.out.print("Enter the name:  ");  //prompts user to enter the name of sibling

 name = input.nextLine();  //scans and reads the input name from user

 System.out.print("Enter the age:  ");  //prompts user to enter the age of sibling

 age = input.nextInt();   //scans and reads the age from user

 System.out.print("Enter the weight:  ");  //prompts user to enter the weight of sibling

 weight = input.nextInt(); } }   //scans and reads the input weight from user

Explanation:

Here is the TestSibling class that contains main method:

public class TestSibling {   //class name

public static void main (String[] args) {   //main method

String name;  // to hold name of sibling

int age, weight;   // to hold age and weight of sibling

Sibling sib1, sib2, sib3;   // objects of Sibling class

sib1 = new Sibling ();  // creates object of class Sibling for sibling 1 and calls constructor

sib1.getInput();   // calls getInput method using sib1 object to get the name, age and weight of sibling 1

sib2 = new Sibling ();  // creates object of class Sibling for sibling 2 and calls constructor

sib2.getInput();   //calls getInput method using sib2 object to get the name, age and weight of sibling 2

sib3 = new Sibling ();  //creates object of class Sibling for sibling 3 and calls constructor

sib3.getInput();   //calls getInput method using sib3 object to get the name, age and weight of sibling 3

Sibling youngest=null, lightest=null;    //holds the youngest age and lightest weight of siblings

if (sib1.getAge( )<= sib2.getAge( ) && sib1.getAge( ) <= sib3.getAge( ) )   /*if condition checks if age of sibling 1 is less than or equals to that of sibling 2 and sibling 3,  using object of each sibling and getAge method to access age. the logical operator && AND is used so that if condition evaluates to true if sib1 is younger than both sib2 and sib3 */

{ youngest=sib1;}   //if the above condition is true then sets sib1 as youngest

else if (sib2.getAge( ) <= sib1.getAge( ) && sib2.getAge( ) <= sib3.getAge( ) )   // else if condition checks if age of sibling 2 is less than or equals to that of sibling 1 and sibling 3

{youngest=sib2;}   // if above condition is true then sets sib2 as the youngest

else   //if none of the above condition is true then this means that the third has the lowest age

{            youngest=sib3;    }    //sets sib3 as the youngest

if (sib1.getWeight( ) <= sib2.getWeight( ) && sib1.getWeight( ) <= sib3.getWeight( ) )   //if condition checks if weight of sibling 1 is less than or equals to that of sibling 2 and sibling 3,  using object of each sibling and getAge method to access weight of each sibling

          { lightest=sib1; }   //if the above condition is true then sets sib1 as having the lightest weight

else if (sib2.getWeight( ) <= sib1.getWeight( ) && sib2.getWeight( ) <= sib3.getWeight( ) )  // else if condition checks if weight of sibling 2 is less than or equals to that of sibling 1 and sibling 3

{lightest=sib2; }  //if the above condition is true then sets sib2 as the lightest

else  //if none of the above condition is true then this means that the third has the lightest weight

{ lightest=sib3;   }  //sets sib3 as the lightest

System.out.println("The lightest sibling: " + lightest.getName() +" " + lightest.getAge()+" "+ lightest.getWeight());  } } //calls the getName() getAge() and getWeight() method using object lightest to print the lightest of the siblings

System.out.println("The youngest sibling: " + youngest.getName() +" " + youngest.getAge()+" "+ youngest.getWeight());  //calls the getName() getAge() and getWeight() method using object youngest to print the youngest of the siblings

The screenshot of the output is attached.

Which connection device enables you to access outside networks such as the
Internet? Choose the answer.
switch
router
network adapter
hub

Answers

Router
Your router controls everything the IP address the gataway all that
Router because without it you wouldnt be able to connect to the internet

Which elements of photography does the Iso rating apply

Answers

Answer:its sensitivity to light if it has a lower iso it probably would need more alumination or a longer shuter speed.

Explanation:

Answer:

the film or the sensor

Explanation:

In which situation would saving a Word document as a PDF be most useful?

Answers

It can be useful in many ways, from saving it for something important for work to a test for school. I usually use it for my classwork and tests.

Hope this helped if it did may i have brainliest?

Answer:

when users who want to view a document do not have Word

Explanation:

edge 2021

Using math functions Given three floating-point numbers x, y, and z, output x to the power of z, x to the power of (y to the power of z), the absolute value of (x minus y), and the square root of (x to the power of z). Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print('{:.2f} {:.2f} {:.2f} {:.2f}'.format(your_value1, your_value2, your_value3, your_value4)) Ex: If the input is: 5.0 1.5 3.2
the output is: 172.47 340002948455826440449068892160.00 6.50 262.43

Answers

Answer:

import math

x = float(input())

y = float(input())

z = float(input())

value1 = pow(x, z)

value2 = pow(x, pow(y, z))

value3 = abs(x - y)

value4 =  math.sqrt(pow(x, z))

print('{:.2f} {:.2f} {:.2f} {:.2f}'.format(value1, value2, value3, value4))

Explanation:

*The code is in Python.

Ask the user to enter x, y, and z as floating point numbers

Calculate the each expression using math functions, pow - calculates the power, abs - calculates the absolute value, and sqrt - calculates the square root

Print the values in required format

Note that the given output is not correct. It must be:

172.47 361.66 3.50 13.13

What is the default layout position for images added to a Word 2016 document?

A) square, where the text wraps around an image around a square border
B) through, where the text wraps around an image with irregular borders
C) in front of the text, where the image is placed over the text
D) in-line, with the text where the text stays with the image

Answers

Answer:

D

Explanation:

Hope it works

Answer:

D) in-line, with the text where the text stays with the image

Explanation:

Just did it in ED.

No Loops, or if statements, or arrays allowed for this program. You will receive a zero if your program contains any loop, if statement, or array. You need a program to maintain information about your stocks. Assume that you have the following stocks:
Stock Name Number of Shares Buying Price Current Price Yearly Fees
Per Share Per Share
IBM 155 $15.33 $13.33 $5.00
ORACLE 375 $11.77 $12.25 $3.50
SUN MICRO 350 $27.55 $35.75 $12.25
LINKSYS 85 $25.35 $23.34 $6.00
CISCO 50 $45.36 $50.86 $1.50
You must use the data from this table for you Program Set 2 submission.
Write a C program that will perform the following tasks:
Task 1: Allow the user to enter in the data for each stock. Stock name, Number of shares, Buy Price, Current Price and Yearly fees.(The user will not enter the $'s.)
Task 2: Calculate the Initial Cost, Current Cost, and Profit for each stock. The formulas to use are: Initial Cost

Answers

Answer:

Here is the C program:

#include <stdio.h> //to use input output functions

int main(){ //start of main function

    char *stock_name=NULL; //to store stock name (this is used instead of using char type array)

    int shares; //to store number of shares

    float buy_price; //to store the buy price

    float cur_price; //to store the current price

    float fees; //to store the fees

    double initial_cost; //to store the computed initial cost

    double current_cost; //to store the value of computed current cost

    double profit; //to store the calculated value of profit

printf("enter stock name ");  //prompts to enter stock name

scanf("%m[^\n]",&stock_name); //reads the input stock name

printf("enter number of shares "); //prompts to enter number of shares

scanf("%d", &shares); //reads the input number of shares

printf("enter the buy price, current price and fees "); //prompts to enter buy price, current price and fees values from user

scanf("%f %f %f", &buy_price, &cur_price, &fees); //reads the values of buy price, current price and fees from user

    initial_cost = shares * buy_price; //computes initial cost

    current_cost = shares *cur_price; //computes current cost

    profit = current_cost - initial_cost - fees; //computes profit for each stock

printf("The stock name is: %s\t\n",stock_name); //displays the stock name

printf("The number of shares: \t%d\t\t\n",shares); //displays the number of shares

printf("The buy price is:\t$\t %0.2f\t\n",buy_price); //displays the buy price

printf("The current price is:\t$\t %0.2f\n",cur_price); //displays the current price

printf("The fees are:\t\t$\t %0.2f\n",fees); //displays the fees

printf("The initial cost is:\t$\t %0.2f\n",initial_cost); //displays the computed initial cost

printf("The current cost is:\t$\t %0.2f\n",current_cost); //displays the computed current cost

printf("The profit is:\t\t$\t %0.2f\n",profit);//displays the computed profit for each stock

return 0;  }

       

Explanation:

Lets say the user input IBM, 150, 11.33 13.33 and 5.00 as stock name, number of shares, buy price, current price and fees values.

So,

stock_name = "IBM"

shares = 150

buy_price = 11.33

cur_price = 13.33

fees = 5.00

Now initial cost is computed as:

  initial_cost = shares * buy_price;

This becomes:

  initial_cost = 150* 11.33

  initial_cost = 1699.5

Next current cost is computed as:

    current_cost = shares *cur_price;

This becomes:

    current_cost = 150*13.33

    current_cost = 1999.5

Next the profit is computed as:

    profit = current_cost - initial_cost - fees;

This becomes:

    profit = 1999.5 - 1699.5 - 5.00

     profit =     295

These values are displayed on the output screen up to 2 decimal places. So the output of the entire program is:

The stock name is: IBM                                                                                                                        The number of shares:   150                                                                                                                   The buy price is:         $        11.33                                                                                                        The current price is:   $        13.33                                                                                                        The fees are:               $        5.00                                                                                                         The initial cost is:        $        1699.50                                                                                                      The current cost is:     $        1999.50                                                                                                      The profit is:                 $        295.00

The screenshot of the output is attached.

Select the correct answer.
Which decimal number is equivalent to this binary number?
001100112
A.
15
OB.
51
OC.
204
D.
240

Answers

The answer is B , 51.

Which kind of file would be hurt most by lossy compression algorithm

Answers

Answer:

Answer is a text document

Explanation:

"Text document" is the file that would be hurt most by the lossy compression algorithm.

Audio, as well as picture data (text document), are compressed with crushing defeat to start taking benefit of the unique vision as well as listening or auditory shortcomings.More such documents including software should have been stored without any information leakage as well as corruption.

Thus the above answer is appropriate.

Learn more about the text document here:

https://brainly.com/question/18806025

#include using namespace std; int main( ) { const int NUM_ROWS = 2; const int NUM_COLS = 2; int milesTracker[NUM_ROWS][NUM_COLS]; int i = 0; int j = 0; int maxMiles = -99; // Assign with first element in milesTracker before loop int minMiles = -99; // Assign with first element in milesTracker before loop milesTracker[0][0] = -10; milesTracker[0][1] = 20; milesTracker[1][0] = 30; milesTracker[1][1] = 40;

Answers

Answer:

#include <iostream>

using namespace std;

int main()

{

   const int NUM_ROWS = 2;

   const int NUM_COLS = 2;

   int milesTracker[NUM_ROWS][NUM_COLS];

   int i = 0;

   int j = 0;

   int maxMiles = -99; // Assign with first element in milesTracker before loop

   int minMiles = -99; // Assign with first element in milesTracker before loop

   milesTracker[0][0] = -10;

   milesTracker[0][1] = 20;

   milesTracker[1][0] = 30;

   milesTracker[1][1] = 40;

   

   maxMiles = milesTracker[0][0];

   minMiles = milesTracker[0][0];

   

   for (i = 0; i < NUM_ROWS; i++){

       for (j = 0; j < NUM_COLS; j++){

           if (milesTracker[i][j] > maxMiles){

               maxMiles = milesTracker[i][j];

           }

           if (milesTracker[i][j] < minMiles){

               minMiles = milesTracker[i][j];

           }

       }

   }

   

   cout << "Min: " << minMiles << endl;

   cout << "Max: " << maxMiles << endl;

   return 0;

}

Explanation:

It seems you want to find the min and max value in the array. Let me go through what I added to your code.

Set the maxMiles and minMiles as the first element in milesTracker

Create a nested for loop that iterates through the milesTracker. Inside the loop, check if an element is greater than maxMiles, set it as maxMiles. If an element is smaller than minMiles, set it as minMiles.

When the loop is done, print the minMiles and maxMiles

Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two inputs, current price and last month's price (both integers). Then, output a summary listing the price, the change since last month, and the estimated monthly mortgage computed as (current_price * 0.051) / 12.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print('{:.2f}'.format(your_value))
Ex: If the input is:
200000
210000
the output is:
This house is $200000. The change is $-10000 since last month.
The estimated monthly mortgage is $850.00.
Note: Getting the precise spacing, punctuation, and newlines exactly right is a key point of this assignment. Such precision is an important part of programming.
main.py
current_price = int(input())
last_months_price = int(input())
''' Type your code here. '''

Answers

Answer:

current_price = int(input())

last_months_price = int(input())

change = current_price - last_months_price

mortgage = (current_price * 0.051) / 12

print('This house is $' + str(current_price) + '. The change is $' + str(change) + ' since last month.')

print('The estimated monthly mortgage is ${:.2f}.'.format(mortgage))

Explanation:

Ask the user to enter the current price and last month's price

Calculate the change, subtract last month's price from the current price

Calculate the mortgage using the given formula

Print the results in required format

An employee is paid at a rate of $16.78 per hour for the first 40 hours worked in a week. Any hours over that are paid at the overtime rate of oneand-one-half times that. From the worker’s gross pay, 6% is withheld for Social Security tax, 14% is withheld for federal income tax, 5% is withheld for state income tax, and $10 per week is withheld for union dues. If the worker has three or more dependents, then an additional $35 is withheld to cover the extra cost of health insurance beyond what the employer pays. Write a program that will read in the number of hours worked in a week and the number of dependents as input and will then output the worker’s gross pay, each withholding amount, and the net take-home pay for the week. For a harder version, write your program so that it allows the calculation to be repeated as often as the user wishes. If this is a class exercise, ask your instructor whether you should do this harder version.

Answers

Answer:

Here is the C++ program:

#include<iostream>  // to use input output functions

using namespace std;  //to access objects cin cout

int main() {  //start of main function

int hrsWorked;  //stores the number of hours worked

   int dependents;  //stores the number of dependents

double grossPay;  //stores the gross pay

char choice;  //store the value for choice of user to continue

do {  //loop that keeps repeating as often as the user wishes

  cout<<"Enter number of hours worked in a week: ";  // prompts user to enter number of weeks

  cin>>hrsWorked;  //reads input value for number of hours worked

  cout<<"Enter number of dependents : "; // prompts user to enter number of dependents

  cin>>dependents;  //reads input value for number of dependents  

      if(hrsWorked>40)  //if hours worked are more than 40

       {grossPay = ((40 * 16.78) + (hrsWorked-40)*(16.78*1.5));  }  //employee is paid at the overtime rate of one and-one-half times

       else  //if hours worked are not more than 40

      { grossPay = (hrsWorked*16.78);}  // employee is paid at a rate of $16.78 per hour        

      double ssTax = 0.06* grossPay ;  //computes 6% Social Security tax withheld from gross pay

      double fIncomeTax = 0.14* grossPay;  //computes 14% federal income tax withheld from gross pay

      double sIncomeTax = 0.05 * grossPay;  //computes 5% state income tax withheld from gross pay      

   cout<<"worker’s pay: "<<grossPay<<endl;  //displays workers pay

   cout<<"worker’s gross pay after withholding amounts:"<<endl;  //displays workers pay including withholding amounts

   cout<<"withhold amount for state income tax is: "<<sIncomeTax<<endl;  //displays grosspay with state income tax withheld

   cout<<"withhold amount for social security tax is: "<<ssTax<<endl;  //displays grosspay with Social Security tax withheld

   cout<<"withhold amount for federal income tax is: "<<fIncomeTax<<endl;  //displays grosspay with federeal income tax withheld

   cout<<"withhold amount  for union dues is: $10 "<<endl;   // $10 per week is withheld for union dues

if(dependents >= 3) {  //if worker has three or more dependents

cout<<"withhold amount of $35 for health insurance "<<endl;

  grossPay = grossPay - 35;  }  //an additional $35 is withheld to cover the extra cost of health insurance beyond what the employer pays  

    cout<<endl;  //prints a new line

    double take_homepay;  //stores the net take-home pay for the week.

    take_homepay = ((grossPay- ssTax- sIncomeTax - fIncomeTax) - 10);  //compute the net t ake-home pay for the week

cout<<"net amount take-home pay for the week is: "<<take_homepay;  //displays the net take-home pay for the week

    cout<<endl;  //prints a new line

cout<<"\nDo you want to continue? (press y to repeat or any key to quit)";  //ask user to repeat the calculation

cin>>choice;  //reads choice from user

cout<<endl;  //prints a new line

}while(choice =='y' || choice =='Y');  }   //loop continues to execute till user wants to repeat calculations and stops when user presses any key other than y or Y

Explanation:

The program works as follows:

Suppose number of working hours is 40 and number of dependents is 2

hrsWorked = 40

dependents = 2

if(hrsWorked>40) this condition evaluates to false because hrsWorked is equal to 40 so else part executes:

grossPay = (hrsWorked*16.78); this becomes:

grossPay = 40 * 16.78

grossPay = 671.2

double ssTax = 0.06* grossPay ;  this statement withholds 6% Social Security tax from gross pay. This becomes:

ssTax = 0.06* 671.2;

ssTax = 40.272

double fIncomeTax = 0.14* grossPay;  this statement withholds 14% federal income tax from gross pay. This becomes:

fIncomeTax = 0.14* 671.2;

fIncomeTax = 93.968

double sIncomeTax = 0.05 * grossPay;  this statement withholds 5% state income tax from gross pay. This becomes:

sIncomeTax = 0.05 * 671.2

sIncomeTax = 33.56

if(dependents >= 3) this condition is false because number of dependents is 2

Next to compute  net take-home pay the program control moves to the statement:

take_homepay = ((grossPay- ssTax- sIncomeTax - fIncomeTax) - 10)

this becomes:

take_homepay = ((671.2 - 40.272 - 33.56 - 93.968) - 10)

Note that the 10 here is the $10 per week which is withheld for union dues.

take_homepay = ((671.2 - 40.272 - 33.56 - 93.968) - 10)

take_homepay = 503.4 - 10

take_homepay = 493.4

The screenshot of the output of this program is attached.

Write an application that accepts up to 20 Strings, or fewer if the user enters the terminating value ZZZ. Store each String in one of two lists—one list for short Strings that are 10 characters or fewer and another list for long Strings that are 11 characters or more. After data entry is complete, prompt the user to enter which type of String to display, and then output the correct list. For this exercise, you can assume that if the user does not request the list of short strings, the user wants the list of long strings. If a requested list has no Strings, output The list is empty. Prompt the user continuously until a sentinel value, ZZZ, is entered.

Answers

Answer:

count = 20

i = 0

short_strings = []

long_strings = []

while(i<count):

   s = input("Enter a string: ")

   

   if s == "ZZZ":

       break

   

   if len(s) <= 10:

       short_strings.append(s)

   elif len(s) >= 11:

       long_strings.append(s)

   

   i += 1

choice = input("Enter the type of list to display [short/long] ")

if choice == "short":

   if len(short_strings) == 0:

       print("The list is empty.")

   else:

       print(short_strings)

else:

   if len(long_strings) == 0:

       print("The list is empty.")

   else:

       print(long_strings)

Explanation:

*The code is in Python.

Initialize the count, i, short_strings, and long_strings

Create a while loop that iterates 20 times.

Inside the loop:

Ask the user to enter a string. If the string is "ZZZ", stop the loop. If the length of the string is smaller than or equal to 10, add it to the short_strings. If the length of the string is greater than or equal to 11, add it to the long_strings. Increment the value of i by 1.

When the loop is done:

Ask the user to enter the list type to display.

If the user enters "short", print the short list. Otherwise, print the long_strings. Also, if the length of the  chosen string is equal to 0, print that the list is empty.

You need to buy a cable to connect a desktop PC to a router. Which cable should
you get?
Choose the answer.
Cat6 crossover
Cat5e crossover
Cat3 patch
Cat6 patch

Answers

Answer:

Cat 6 patch

Explanation:

Crossover cables are used for connecting NIC cards together - not for connection to a router or switch.

Cat 3 is an older standard with limited speeds (up to 10MB per second).

Cat 6 is the current standard with speeds up to 10GB per second.

what are the uses of joystick​

Answers

Joysticks are often used to control video games, and usually have one or more push-buttons whose state can also be read by the computer. A popular variation of the joystick used on modern video game consoles is the analog stick.

Arrange the following units of storage in descending
order. B, TB,KB, GB,MB

Answers

Answer:

TB,GB,MB,KB,B

Explanation:

Which of the following option may be used to change page size and margins?

Question 7 options:

Data


Tools


View


Page setup

Answers

Answer: D ) page set up

Explanation:

Answer:

Page Set up

Explanation:

"Change page size and margins"

I don't think I have to explain that.

Other Questions
PLEASE ANSWER ASAP WILL MARK BRAINLIESTWhich graph shows an object with constant acceleration? If a DNA molecule is 22% adenine in any organism, which percentage of thymine will that DNA molecule contain? A customer pays a purchase price of $1,375 for a bond. This purchase price could also be referred to as Read and choose the right option. Hola, amigos! Soy Ral, de Espaa. En Espaa we begin the school year en septiembre and our school horario depends on each type of school. Some may run from 9 por la maana through 5 por la tarde, with a two-hour lunch break. Other schools may begin at 9 por la maana and end at 3 por la tarde, which is the typical lunchtime en Espaa. Some schools may have only a one-hour lunch break and may or may not provide a cafeteria for children to eat at the school. Mi amigo Francisco in Costa Rica starts school en diciembre at 7 a.m. every morning. He stays there for about six hours. Francisco tells me that some students go to class either por la maana or por la tarde. Rewrite the sentence to make the pronoun reference clear.Sally told Sarah that she needed to work on her spelling. Question # 2Multiple ChoiceWhich of these scenarios demonstrates why an art director is necessary?A group of theme park designers meet to discuss ideas for a new attraction.An artist graduates from a prestigious school, but cant find work in fine art.An advertising executive looks at a print layout and says, I dont like it. Its too odd-looking.A game designer must take a popular game and design a sequel for it.Question # 3Multiple ChoiceAn applicant for the position of art director has a fine reputation as a designer and innovator, but his supervisor says that he is awkward and uncommunicative around non-artists. Should the artist be hired as art director?No, because he lacks the finesse needed to deal with both creatives and marketing personnel.Yes, because it is more important for an art director to communicate with artists than anyone else.No, because he most likely couldnt take the stress that goes with the job.Yes, because he should be given a chance to improve his social skills.Question # 4Multiple ChoiceThe art director is meeting with the brand strategist. What are they most likely doing?discussing where the copy will be placed in the latest print adcomparing images proposed for an updated logoreviewing the music for an online video commercialbrainstorming ideas for a social media campaign Help right answer please ??A fertilized egg receives 50% of its chromosomes from a sperm and 50% from the egg. Which process ensures that the sperm and egg contain only 50% of the chromosomes of an organism?fertilizationmeiosismitosismutation who is aberham lincon The hungry bird finally stopped hovering overhead, so the caterpillar began to inch along the tree branch again.What is the best synonym for inch as it is used in the sentence?A.creepB.moveC.walkD.crawl What is negative times a negative? What does the underlined word mean in the following sentence?Usamos el teclado para escribir.O keyboardInternetcopierO screen What do (3.9 x 10^2)(4.1 x 10^4) equal A survey of magazine subscribers showed that rented a car during the past months for business reasons, rented a car during the past months for personal reasons, and rented a car during the past months for both business and personal reasons. Round your answers to three decimal places. a. What is the probability that a subscriber rented a car during the past months for business or personal reasons? b. What is the probability that a subscriber did not rent a car during the past months for either business or personal reasons? Help with summarizing 1.10 according to darwin evolution takes place by a process called ? What is halfway between 4/9 and 1/7Please hurry! 2. Name four pronouns that start with the letter t: simplify the following y^-1z^5y^3z^2 2. Look at your computer on your desk at home in the classroom.a. Is the computer moving?i. Yes or No?ii. What reference point did you choose to describe the motion of the computer? Billy cuts 2/5 -inch sections of wood to make a birdhouse roof. He cut 37 sections. How many inches did he cut?