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(prompt("Enter Homework Grade."));
mt1= parseFloat(prompt("Enter Midterm 1 Grade."));
mt2= parseFloat(prompt("Enter Midterm 2 Grade."));
fin= parseFloat(prompt("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?
9 1989
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
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!
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(prompt("Enter Homework Grade."));
mt1= parseFloat(prompt("Enter Midterm 1 Grade."));
mt2= parseFloat(prompt("Enter Midterm 2 Grade."));
fin= parseFloat(prompt("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?????
Heya, Senso. Welcome to TSDN!
In these lines: -
hw=.40*150;
-
mt1=.15*100;
-
mt2=.20*100;
-
fin=.25*100;
-
Did you mean to use *= instead of = ?
Heya, Senso. Welcome to TSDN!
In these lines: -
hw=.40*=150;
-
mt1=.15*=100;
-
mt2=.20*=100;
-
fin=.25*=100;
-
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?
Heya, Senso.
I meant this:
Heya, Senso.
I meant this:
Really having a time,. can't believe how hard this is. Still not working for me!
Still having a really tough time, program is not doing what it should....Help!
Still having a really tough time, program is not doing what it should....Help!
So what is it doing instead?
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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...
| |