Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
body{
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
.container{
text-align: center;
padding-top: 14%;
height: 35vw;
width: 100%;

}
.child {
background-color: #354f52;
display: inline-block;
padding: 20px 100px;
border: 3px black solid;
border-radius: 30px;


}

.header {
background-color: #457b9d;
display: inline-block;
padding: 0px 10px;
border: 2px solid black;
border-radius: 10px;
color: #f2f2f2;
}
.inputs{
/* border-radius: 5px; */
/* color: #457b9d; */
margin: 10px;
font-family: sans-serif;

}
.inputs >input{
width: 250px;
height: 30px;
border-radius: 7px;
}

.inputs>button{
/* color: aqua; */
margin-top: 10px;
border-radius: 5px;
background-color: brown;
width: 100px;
height: 40px;
font-size: 15px;
color: white;
}
33 changes: 32 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
import "./App.css";
import { useState } from "react";

function App() {
const[input, setInput ]= useState()
const[total, setTotal]= useState()

function calcTip(){
if (input>=50&& input<=300){
let tip1= input*0.15
let total1 = input * 0.15 / 0.15 + input * 0.15
let final= `your bill is ${input} and your tip is ${tip1} and your total is ${total1}`
setTotal(final)
} else{
let tip2= input*0.20
let total2 = input * 0.20/ 0.20 + input * 0.20
let final= `your bill is ${input} and your tip is ${tip2} and your total is ${total2}`
setTotal(final)
}
}

return (
<div>
<h1>Hello World</h1>
<div class="container">
<h1>TIP CALCULATOR</h1>
<div class="inputs">
<input onChange={(e)=>setInput(e.target.value)} placeholder="Ener your bill" type="number"/>
<br/>
<button onClick={calcTip}>Calculate</button>
<br/>
<h2 class="restult">{total} </h2>



</div>
</div>

</div>
);
}
Expand Down