473,659 Members | 2,886 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Learning Javascript

6 New Member
Hi, I am learning Java, and working on a program that reads the grades of homework, midterm1, midterm2, and final, and calculates the overall average and final letter grade. Assume that the maximum point of the homework is 150, and those of midterm1, midterm2 and final are 100. The overall average is to be calculated as follows:



homework: 40%

midterm1: 15%

midterm2: 20%

final: 25%

And am suppose to use a function that calculates the overall average, and another function that calculates the final grade. You are also to use an
extended if or a switch statement in the program.

I have this so far;

[HTML]vr hw,mt1,mt2,fin, avg;

hw= parseFloat(prom pt("Enter Homework Grade."));
mt1= parseFloat(prom pt("Enter Midterm 1 Grade."));
mt2= parseFloat(prom pt("Enter Midterm 2 Grade."));
fin= parseFloat(prom pt("Enter Final Grade."));



if(hw>150)
document.write( "Homework points are to large.<BR>");
if(hw<0)
document.write( "Homework points are to small.<BR>");
if(mt1>100)
document.write( "Midterm 1 points are to large.<BR>");
if(mt1<0)
document.write( "Midterm 1 points are to small.<BR>");
if(mt2>100)
document.write( "Midterm 2 points are to large.<BR>");
if(mt2<0)
document.write( "Midterm 2 points are to small.<BR>");
if (fin>100)
document.write( "Final points are to large.<BR>");
if (fin<0)
document.write( "Final points are to small.<BR>");

hw=.40*150;
mt1=.15*100;
mt2=.20*100;
fin=.25*100;

avg=(hw+mt1+mt2 +fin);


var grade;

if (avg<=50)
document.write( "Grade is an F.");
else if(avg<=60)
document.write( "Grade is an D.");
else if(avg<=70)
document.write( "Grade is an C.");
else if(avg<=80)
document.write( "Grade is an B.");
else if (avg<=90)
document.write( "Grade is an A.");

</SCRIPT>
</HEAD>
<BODY>

</BODY>
</HTML>[/HTML]

What am I not doing correctly?
Sep 30 '07 #1
9 2016
JosAH
11,448 Recognized Expert MVP
What am I not doing correctly?
1) posting in the wrong section;
2) mistaking Java for Javascript.

I'll move your question to the Javascript forum section; see the blue menu bar
near the top of this page: select 'Forums' and 'Javascript/Ajax'.

kind regards,

Jos
Sep 30 '07 #2
senso
6 New Member
1) posting in the wrong section;
2) mistaking Java for Javascript.

I'll move your question to the Javascript forum section; see the blue menu bar
near the top of this page: select 'Forums' and 'Javascript/Ajax'.

kind regards,

Jos

Thanks, I hope with my question in the correct area now, I will get the help I need to finish my assignment!
Sep 30 '07 #3
senso
6 New Member
Hi, I am learning Java, and working on a program that reads the grades of homework, midterm1, midterm2, and final, and calculates the overall average and final letter grade. Assume that the maximum point of the homework is 150, and those of midterm1, midterm2 and final are 100. The overall average is to be calculated as follows:



homework: 40%

midterm1: 15%

midterm2: 20%

final: 25%

And am suppose to use a function that calculates the overall average, and another function that calculates the final grade. You are also to use an
extended if or a switch statement in the program.

I have this so far;

[HTML]vr hw,mt1,mt2,fin, avg;

hw= parseFloat(prom pt("Enter Homework Grade."));
mt1= parseFloat(prom pt("Enter Midterm 1 Grade."));
mt2= parseFloat(prom pt("Enter Midterm 2 Grade."));
fin= parseFloat(prom pt("Enter Final Grade."));



if(hw>150)
document.write( "Homework points are to large.<BR>");
if(hw<0)
document.write( "Homework points are to small.<BR>");
if(mt1>100)
document.write( "Midterm 1 points are to large.<BR>");
if(mt1<0)
document.write( "Midterm 1 points are to small.<BR>");
if(mt2>100)
document.write( "Midterm 2 points are to large.<BR>");
if(mt2<0)
document.write( "Midterm 2 points are to small.<BR>");
if (fin>100)
document.write( "Final points are to large.<BR>");
if (fin<0)
document.write( "Final points are to small.<BR>");

hw=.40*150;
mt1=.15*100;
mt2=.20*100;
fin=.25*100;

avg=(hw+mt1+mt2 +fin);


var grade;

if (avg<=50)
document.write( "Grade is an F.");
else if(avg<=60)
document.write( "Grade is an D.");
else if(avg<=70)
document.write( "Grade is an C.");
else if(avg<=80)
document.write( "Grade is an B.");
else if (avg<=90)
document.write( "Grade is an A.");

</SCRIPT>
</HEAD>
<BODY>

</BODY>
</HTML>[/HTML]

What am I not doing correctly?
Allows me to enter points in browser, but is not calculating grades?????
Sep 30 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, Senso. Welcome to TSDN!

In these lines:
Expand|Select|Wrap|Line Numbers
  1. hw=.40*150;
  2. mt1=.15*100;
  3. mt2=.20*100;
  4. fin=.25*100;
  5.  
Did you mean to use *= instead of = ?
Sep 30 '07 #5
senso
6 New Member
Heya, Senso. Welcome to TSDN!

In these lines:
Expand|Select|Wrap|Line Numbers
  1. hw=.40*=150;
  2. mt1=.15*=100;
  3. mt2=.20*=100;
  4. fin=.25*=100;
  5.  
Did you mean to use *= instead of = ?
Now, I am really lost. This program needs to be set up to calculated weighted averages of hw, mt1, mt2 and fin. So far, all I can get it to do is allow me to enter the points for hw, mt1, mt2 and final in browser. I am guessing once these total are entered the percentages need to be used and a grade will be calculated based on avg???? It needs to print grade. which it is not doing?
Sep 30 '07 #6
pbmods
5,821 Recognized Expert Expert
Heya, Senso.

I meant this:
Expand|Select|Wrap|Line Numbers
  1. hw *= 0.40 * 150;
  2.  
Sep 30 '07 #7
senso
6 New Member
Heya, Senso.

I meant this:
Expand|Select|Wrap|Line Numbers
  1. hw *= 0.40 * 150;
  2.  
Really having a time,. can't believe how hard this is. Still not working for me!
Sep 30 '07 #8
senso
6 New Member
Still having a really tough time, program is not doing what it should....Help!
Sep 30 '07 #9
acoder
16,027 Recognized Expert Moderator MVP
Still having a really tough time, program is not doing what it should....Help!
So what is it doing instead?
Oct 1 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2558
by: Sean McCourt | last post by:
Hi I am doing a JavaScript course and learning from the recommed book (JavaScript 3rd Edition by Don Gosslin) Below is one of the exercises from the book. I get this error message when I try to use the calculator. "document.Calculate.Input is null or not an object" Can someone please tell me why this is?
1
9623
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
2
308
by: rich | last post by:
I'd like to improve my webdesign knowledge and learn how to write Javascripts. I have built my own website. I have javascripts on my site that I havent written. I download them and edit them where I need to to fit my site and then put them in. I have dabbed alittle bit into computer programming some years ago. Trying to teach myself and found it overwhelming. So I dont know how the process is going to be in learning javascript. I'm not...
6
1614
by: Helpful person | last post by:
I have written my web site using FrontPage and have disvovered that apart from producing code that does not validate it also creates a horrible structure. I have been teaching myself HTML reasonably successfully and have almost completed rewriting my web. However, a major gap in my knowledge is javascript. I am completely new to javascript and wish to learn this language. I am looking for a book suitable for a beginner javascript...
10
1595
by: Michael Reach | last post by:
Can anyone suggest a really good course in Javascript that my son can take online, starting right away? It should be for someone without much programming experience, and I mean a real course, that covers things properly and gives problems to work, so that someone who puts in the time can really learn it. Or, the same for a book to buy. Thanks
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.