1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
pychu [463]
3 years ago
14

Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a function named newton. This

function expects the input number as an argument and returns the estimate of its square root. The program should also include a main function that allows the user to compute the square roots of inputs from the user and python's estimate of its square roots until the enter/return key is pressed.An example of the program input and output is shown below:Enter a positive number or enter/return to quit: 2 The program's estimate is 1.4142135623746899 Python's estimate is 1.4142135623730951 Enter a positive number or enter/return to quit: 4 The program's estimate is 2.0000000929222947 Python's estimate is 2.0 Enter a positive number or enter/return to quit: 9 The program's estimate is 3.000000001396984 Python's estimate is 3.0 Enter a positive number or enter/return to quit
Computers and Technology
1 answer:
lutik1710 [3]3 years ago
7 0
I’m confused what are you asking
You might be interested in
Write a program that asks the user to enter the amount s/he has budgeted for a month. The amount should be between 1000 and 2000
Elena-2011 [213]

Answer:

The program to this question can be given as:

Program:

  //import package for user input.

import java.util.*;      

//define class

public class Budget                      

{

public static void main(String [] a)            //define main method.

{

//creating Scanner class object.

Scanner ob =new Scanner(System.in);    

//define variable.      

double budgetamount=0, amountspent=0 ,difference=0,total=0,num=0 ;        

int count = 0;                            

System.out.println("How much have you budgeted for the month? :");        //print message.

budgetamount=ob.nextDouble();                             //taking input

       while(budgetamount != 0)           //checkig number greater then 4 digite.

       {

           budgetamount= budgetamount/10;        

           ++count;

       }

       if(count>4)                 //condition

       {

       System.out.println("enter each expense, then type -999 to quit: ");

       while(num!=-999)               //taking expense  

       {

       total=total+num;                 //totaling expense

       num=scan.nextDouble();                  

       }

       if(total<=budgetamount)           //condtion for over budget.

       {

       System.out.print("under budget:");         //print message

       System.out.print(budgetamount-total);

       }

       else

       {

       System.out.print("over budget:");              //for under budget

       System.out.print(total-budgetamount);

       }

       }

       else

       {

       System.out.println("not valid");        //message for number lessthen 4 digit.    

       }                                      

}

}

output:

How much have you budgeted for the month? : 1200.55.

enter each expense, then type -999 to quit: 365.89

556.90

339.98

-999

over budget:1262.77

Explanation:

The explanation of this program can be given as:

In the above program we import the package in that is used for scanner class. This class is used for the input from the user after input we use the while loop and if-else statement. The while loop is the entry control loop It is used for input validation and if-else is used for the checking condition. Then we insert expense that is inserted by the user. Then we calculate under-budgeted and over-budgeted by conditional statement that is if-else. and at the last we print it.

5 0
3 years ago
How would you write this using Java: Use a TextField's setText method to set value 0 or 1 as a string?
katrin [286]

Answer:

Explanation:

The following Java code uses JavaFX to create a canvas in order to fit the 10x10 matrix and then automatically and randomly populates it with 0's and 1's using the setText method to set the values as a String

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.control.TextField;

import javafx.scene.layout.GridPane;

import javafx.stage.Stage;

public class Main extends Application {

   private static final int canvasHEIGHT = 300;

   private static final int canvasWIDTH = 300;

   public void start(Stage primaryStage) {

       GridPane pane = new GridPane();

       for (int i = 0; i < 10; i++) {

           for (int j = 0; j < 10; j++) {

               TextField text = new TextField();

               text.setText(Integer.toString((int)(Math.random() * 2)));

               text.setMinWidth(canvasWIDTH / 10.0);

               text.setMaxWidth(canvasWIDTH / 10.0);

               text.setMinHeight(canvasHEIGHT / 10.0);

               text.setMaxHeight(canvasHEIGHT / 10.0);

               pane.add(text, j, i);

           }

       }

       Scene scene = new Scene(pane, canvasWIDTH, canvasHEIGHT);

       primaryStage.setScene(scene);

       primaryStage.setMinWidth(canvasWIDTH);

       primaryStage.setMinHeight(canvasHEIGHT);

       primaryStage.setTitle("10 by 10 matrix");

       primaryStage.show();

   }

   public static void main(String[] args) {

       Application.launch(args);

   }

}

3 0
2 years ago
The term generally used to describe storage systems that function at high speeds is:
Alinara [238K]
The term to describe storage systems that function at high speeds is primary memory.
6 0
3 years ago
Which of the following rules should be used to keep the appropriate distance between your vehicle and the vehicle in front of yo
S_A_V [24]
I would say two car length rule. I am not sure what the official license rule is or if it has been changed, but originally the rule was 3 seconds usually depending on how fast the car is going. The faster you are going, the longer it takes to stop. So two-car length rule would probably be the best choice. Definitely not A.
8 0
3 years ago
Read 2 more answers
HELLO answer this. Sidney needs to create a decimal number variable that will be added to another number. What kind of variable
kipiarov [429]

Answer:

Option D. float is the correct answer.

Explanation:

Decimal number contains decimal point. Out of all the given data types, float data type store the number with decimal point.

As the number has to be further used for calculations float ahs to be used. Because the numbers can also be stored in string but cannot be used for further calculations.

Hence,

Option D. float is the correct answer.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Heatsinks used to protect cpus in computers from overheating, are shaped so that their surface area is very large. why is that?
    5·1 answer
  • What are the conditions for using still photos in a video program
    6·1 answer
  • Which of the following correctly describes the function of an IP address
    13·1 answer
  • What are 2 plants that grow best in our soil type ​
    9·1 answer
  • What computer is designed to meet the computing needs of several people simultaneously in a small to medium-size business enviro
    5·1 answer
  • The World Wide Web is full of unstructured data. Search engines like Google, Bing and Yahoo have been doing a good job of allowi
    5·1 answer
  • When browsing using certain browsers, if a page is known to be malicious or using phishing techniques in the past a browser may
    5·1 answer
  • 7.5 Code practice Plz answer ASAP
    15·1 answer
  • Communication media that use an antenna for transmitting data through air or water are called _____.
    14·1 answer
  • Simple example of hybrid computer​
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!