/    Sign up×
Community /Pin to ProfileBookmark

help with simple program

I am new to prgramming. I was wondering if someone can give me some help programming a simple tip calculator using javascript on Notepad ++. The tip calculator should accept as input both the subtotal and percent tip desired.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@ZeroKilledApr 22.2009 — tip calculator remind me of one i did a very long time ago, days in which i was a really bad newbie! differ in that instead of calculating from a percentage you type a fixed number for tip and it display the percentage that is applied to an individual item. maybe you can grasp some idea so you can start writing your own calculator. advise, try something by yourself, otherwise you would never be able to write something alone.

[upl-file uuid=b8d21980-a21d-4c1b-9c13-5bf39fa38aeb size=3kB]tip.zip[/upl-file]
Copy linkTweet thisAlerts:
@sogu818authorApr 22.2009 — The thing is i am really new, like intensely new to programming. This is actually just for a class assignment. This seems really complicated for me, is there anything simpler. My teacher gave us an example and it was a lot simpler. The only difference between the example and the assignment is that now I think were supposed to use a different function(multiply instead of add).

this is the code we did in class:

<HTML>

<HEAD>

<TITLE>My Calculator</TITLE>

<SCRIPT Language="JavaScript">

function adder (x,y)

{

total = Number(x) + Number(y)

document.Calc.Answer.value = total
}
</SCRIPT>
</HEAD>

<BODY>
<CENTER><H1>My Calculator Webpage</H1></CENTER>
<HR>
<FORM Name="Calc">
Enter the Percent tip desired
<BR>
<INPUT Type="Text" Name="Num1">
<BR>
Enter the Subtotal of your bill
<BR>
<INPUT Type="Text" Name="Num2">
<BR>
The Tip Is
<BR>
<INPUT Type="Text" Name="Answer">
<BR>
<INPUT Type="Button" Name="Enter" Value="Enter" onClick=" adder(Num1.value,Num2.value)">
</FORM>

</BODY>


Now , we have to create a similar program only a tip calculator that utilizes inputs for a subtotal, tip percentage desired, and final tip amount. Please help!!!!!!

</HTML>
Copy linkTweet thisAlerts:
@ZeroKilledApr 22.2009 — read [url=http://www.w3schools.com/jS/js_operators.asp]javascript operator[/url]. you have to simply change an operator and that is all, i guess, unless it don't give you the desired result.
Copy linkTweet thisAlerts:
@ShortsApr 22.2009 — Pretty much first write down what the algorithm is (fancy word for a sequence of instructions, or what the bloody thing does ? ).

Looking at what you posted, ZeroKilled is right, looks like one line of code needs to be changed.

Psuedo-algorithm (not too detailed): You have the subtotal (Num1). All you have to do is add to that the tip percentage (Num2) of a subtotal (Num1) and return it at the end.

Don't forget two things either, 'order of operation' when it comes to math as well as converting a percentage into a decimal ( decimal = percentage/100 ).

Could give you the answer but that'd defeat the purpose of the homework assignment :T plus I never did homework back then, not going to now. ?
×

Success!

Help @sogu818 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...