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
777dan777 [17]
2 years ago
5

Create a simple JavaScript calculator.

Computers and Technology
1 answer:
Gre4nikov [31]2 years ago
3 0

Answer: edit out anything you dont need

<!DOCTYPE html>  

<html lang = "en">  

<head>  

<title> JavaScript Calculator </title>  

 

<style>  

h1 {  

   text-align: center;  

   padding: 23px;  

   background-color: skyblue;  

   color: white;  

   }  

 

#clear{  

width: 270px;  

border: 3px solid gray;  

   border-radius: 3px;  

   padding: 20px;  

   background-color: red;  

}  

 

.formstyle  

{  

width: 300px;  

height: 530px;  

margin: auto;  

border: 3px solid skyblue;  

border-radius: 5px;  

padding: 20px;  

}  

 

 

 

input  

{  

width: 20px;  

background-color: green;  

color: white;  

border: 3px solid gray;  

   border-radius: 5px;  

   padding: 26px;  

   margin: 5px;  

   font-size: 15px;  

}  

 

 

#calc{  

width: 250px;  

border: 5px solid black;  

   border-radius: 3px;  

   padding: 20px;  

   margin: auto;  

}  

 

</style>  

 

</head>  

<body>  

<h1> Calculator Program in JavaScript </h1>  

<div class= "formstyle">  

<form name = "form1">  

     

   <!-- This input box shows the button pressed by the user in calculator. -->  

 <input id = "calc" type ="text" name = "answer"> <br> <br>  

 <!-- Display the calculator button on the screen. -->  

 <!-- onclick() function display the number prsses by the user. -->  

 <input type = "button" value = "1" onclick = "form1.answer.value += '1' ">  

 <input type = "button" value = "2" onclick = "form1.answer.value += '2' ">  

 <input type = "button" value = "3" onclick = "form1.answer.value += '3' ">  

  <input type = "button" value = "+" onclick = "form1.answer.value += '+' ">  

 <br> <br>  

   

 <input type = "button" value = "4" onclick = "form1.answer.value += '4' ">  

 <input type = "button" value = "5" onclick = "form1.answer.value += '5' ">  

 <input type = "button" value = "6" onclick = "form1.answer.value += '6' ">  

 <input type = "button" value = "-" onclick = "form1.answer.value += '-' ">  

 <br> <br>  

   

 <input type = "button" value = "7" onclick = "form1.answer.value += '7' ">  

 <input type = "button" value = "8" onclick = "form1.answer.value += '8' ">  

 <input type = "button" value = "9" onclick = "form1.answer.value += '9' ">  

 <input type = "button" value = "*" onclick = "form1.answer.value += '*' ">  

 <br> <br>  

   

   

 <input type = "button" value = "/" onclick = "form1.answer.value += '/' ">  

 <input type = "button" value = "0" onclick = "form1.answer.value += '0' ">  

   <input type = "button" value = "." onclick = "form1.answer.value += '.' ">  

   <!-- When we click on the '=' button, the onclick() shows the sum results on the calculator screen. -->  

 <input type = "button" value = "=" onclick = "form1.answer.value = eval(form1.answer.value) ">  

 <br>  

 <!-- Display the Cancel button and erase all data entered by the user. -->  

 <input type = "button" value = "Clear All" onclick = "form1.answer.value = ' ' " id= "clear" >  

 <br>  

   

</form>  

</div>  

</body>  

</html>  

Explanation:

You might be interested in
The part of the poppet valve that contacts the valve seat is called the A. face. B. margin. C. head. D. stem.
Phantasy [73]
It should be A face, I think
6 0
2 years ago
Read 2 more answers
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
2 years ago
When a typist changes from a conventional typewriter to a word processor, his typing schema will have to _____ to incorporate th
Elis [28]
<span>The schema will have to accommodate to make the person more easily able to perform the new task. Accommodation allows the new information to be made a part of a schema without changing the overall concepts in the schema. The schema itself stays unchanged for the most part, but the new information is more of a "tweak" to the schema than a full-on update.</span>
8 0
3 years ago
Which key(s) will launch the Spelling Checker dialog box? F8 F7 Ctrl+H F2
KIM [24]

Answer:

F7

Explanation:

Mostly in MS Office products, although a lot of other products will mimic the same well known key sequences as a way of enticing you to their platform.

6 0
2 years ago
Read 2 more answers
Word processing programs have different view options that you can use depending on the tasks your performing
inysia [295]

Answer:

Microsoft Word has five types of views for a document, and there are a different set of advantages with each of them. There is a full-screen reading option, print layout, web layout, Draft and the Outline, and you can find what purpose they server through their name. And you can change the views of a document in two ways. You can either hit the View tab or you can select a certain view from the View tab. Or you can make use of the view button which is next to the zoom slider, which you can see at the bottom right section of the work space. Let's have a look at each of them now.

Explanation:

Microsoft Word has five types of views for a document, and there are a different set of advantages with each of them. There is a full-screen reading option, print layout, web layout, Draft and the Outline, and you can find what purpose they server through their name. And you can change the views of a document in two ways. You can either hit the View tab or you can select a certain view from the View tab. Or you can make use of the view button which is next to the zoom slider, which you can see at the bottom right section of the work space. Let's have a look at each of them now.

Word Views

The Print Layout View

Its the default one, and you will find this one as you open the document. It's best when you are documenting with things such as images, footers, columns headers, etc. And each of the components is going to be visible. You will hence get a view of documents, and how it looks like as per the page breaks.

The full-screen reading view is for reading purposes. It also shows how a printed page will look like.

Web Layout View

This gives us a view of how the document will look like on the web page. And the text gets wrapped to fit into the view if required.

Outline View

This helps when you want to move the sections in your documents, or if you are creating an outline.

Draft View

This will help you to quickly edit the text with the document being opened as a draft, and the headers and footers cannot be viewed in this view.

5 0
3 years ago
Other questions:
  • Which of the following statements is false?
    10·1 answer
  • Describe two ways in which an organizer can assist in taking notes
    8·2 answers
  • Jeffrey works with a huge database of spreadsheet records each day. To organize and identify these spreadsheets, he wants to ass
    7·2 answers
  • When transporting data from real-time applications, such as streaming audio and video, which field in the ipv4 header can be use
    14·1 answer
  • 3. The term integration refers to the ability to
    6·1 answer
  • Given a String variable response that has already been declared, write some code that repeatedly reads a value from standard inp
    10·1 answer
  • You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?
    5·1 answer
  • linda has written a program that works well on various operating systems, but she needs to increase the readability of the progr
    5·1 answer
  • Please answer me <br> in Assignment - Algorithms
    10·1 answer
  • Drag each tile to the correct box.
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!