Java Code - Scoring Of A Surfing Competition
Mar 26, 2014
I have a task and need to write a program to assist with the scoring of a surfing competition. The organizers at this point are unsure of the exact number of judges or competitors, but they do know that there will be between 2 and 8 judges, and between 3 and 6 competitors. Each competitor is to be given a colour, red, blue, yellow, green, white, or black to compete under. (ie competitor # 1 is red, competitor # 2 is blue, etc. ) The judges enter a score for each competitor, the highest being the number of competitors, the lowest being 1. E.g. if there are 4 competitors, the winning score is 4, second is 3, third is 2 and forth (last) is 1.
If there were 4 competitors, a judges scorecard could look as follows:
Judge # 1
CompetitorRedBlueYellowGreen
Score2143
This ranks the Yellow competitor 1st, Green 2nd, red 3rd and blue 4th or last.
At the end of the day, the organizers would like to be able to summarise the scores as follows:
A histogram of the number of first places that each competitor scoredA table of preferences that shows the number of times each place was awarded to the competitors (ie if competitor Blue was ranked second by three judges, the number 3 should appear in the table for 2nd place for the Blue competitorTotal scores for each competitor.
They would also like to be able to print out the raw data of the final scores. Your program should verify all data entered to ensure that only correct data types with in the expected ranges are entered. Your program should also give users the opportunity to choose how they wish to look at the data, and give them the option of looking at it more than once.
View Replies
ADVERTISEMENT
Feb 9, 2014
Judges are scoring divers and I need to create a table of scores for each diver given by 7 judges. In the second for statement, I want
Java Code: for(int column = 0 ; column < judges[row].length ; column++) mh_sh_highlight_all('java');
to be
Java Code: diver[row].length mh_sh_highlight_all('java');
Instead of judges. Because the total number of divers would like exceed the number of judges, and I believe this is limiting the number of columns to the number of judges. When I use divers though, an error occurs, saying that "int cannot be dereferenced".
Java Code:
public float inputValidScore(){
int Num_Judges = 7;
System.out.print("Enter number of contestants: " );
int diver = input.nextInt();
float [] [] judges = new float[Num_Judges] [diver];
[Code] ....
The above is just a method within the rest of the code.
View Replies
View Related
Nov 29, 2014
Many classes calculate a final grade by using a weighted scoring system. For example, "Assignments" might be worth (weighted at) 40% of your final grade. To calculate the portion of the final grade contributed by the Assignments category, the teacher takes the average of all assignments in the category and multiplies it by the weight (40%). So if a student averaged 90% on all assignments, the teacher would take 40% of 90%, or 36 as the weighted average score for the assignment portion of the the final score. The teacher then calculates the weighted average score for each of the other categories (Quizzes, Midterm Exam, Final Exam, etc.), adds them all together to come up with the final score, and assigns a letter grade based on that score.
Write a Java program that allows the teacher to calculate the grade for a student.
Specification :
Prompt the user to enter the Student ID number, first name, last name, and the average score for each of the following categories:
Assignments (worth 50%)
Quizzes (worth 20%)
Midterm Exam (worth 10%)
Final Exam (worth 20%)
Calculate the weighted average score for each category and the total score for the student. Next assign a letter grade as follows:
90 - 100 = A
80 - 89 = B
70 - 79 = C
60 - 69 = D
59 and below = E
Print the results in the following format:
Name: [Last Name], [First Name]
Student ID: [Student ID]
Assignments: [weighted average]
Quizzes: [weighted average]
Midterm Exam: [weighted average]
Final Exam: [weighted average]
Total: [total score]
Final Grade: [letter grade]
Prompt the user to either enter another student or to quit. Continue the process until the user chooses to quit.
I almost done everything but I cant calculate a total score for the student or Assign a letter grade based on the score!!!!
package teacher_grade;
import java.util.Scanner;
public class teachergradeing {
public static void main (String[] args) {
//Scanner objective
[Code] ....
View Replies
View Related
Oct 24, 2014
I want to develop a Java program that uses OpenScript APIs to test my applications. The OpenScript framework automatically creates the Java Code so I was thinking of either using this code or create my own using the APIs.
I tried both options using NetBeans but I'm getting errors everywhere starting with the library import. I'm pretty new to Java so I'm sure I'm missing a lot of things here. I pasted the code below from the OpenScript framework that want to use in a stand-alone file for your reference.,
import oracle.oats.scripting.modules.basic.api.*;
import oracle.oats.scripting.modules.browser.api.*;
import oracle.oats.scripting.modules.functionalTest.api.*;
import oracle.oats.scripting.modules.utilities.api.*;
import oracle.oats.scripting.modules.utilities.api.sql.*;
[Code] ....
View Replies
View Related
Nov 30, 2014
how do we get the following numbers (1 2 3 5 8 13 21 34 55 89) out of the following code? I can't get my head around this loop....
HTML Code:
public class Fabnoci{
public static void main(String[] args)
{
int n=10,i,f0=1,f1=1,f2=1;
for(i=1;i<=n;i++)
{
f2=f0+f1;
[code]....
View Replies
View Related
Jul 2, 2014
i have made a phone directory and i have also maintained a database for this. i want on clicking the next button each row from database table display one by one on the GUI into their relevant text Fields. i have written this code , this code show the last row of the table on single click on next button. i want one by one row on each next button click.
private void next_contactActionPerformed(java.awt.event.ActionE vent evt) {
try {
String Url = "Jdbc:OdbcirDSN";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(Url,"sa","mysql");
String sql = "SELECT * FROM PersonInformation";
PreparedStatement pstmt = con.prepareStatement(sql,
ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR _UPDATABLE);
[code].....
View Replies
View Related
Oct 7, 2014
you will be making four variables (2 primitive integers and 2 Account Objects). You will be following the steps detailed below. The challenge is to understand exactly what is happening and why. Start by coding the following two methods in a java file.
Start your main method with four variables: a, b c, d. a and by should be integer data, set them to be the values 10 and 20 respectively. Variables c and d should be Account Objects. The first account © is Ted, has $70,000 as his balance. The second account (d) is Joe, he has only $15,000 as his balance. Their account numbers are up to you to determine.Next, please print out the four variables: a, b, c, and d. Make sure that you label which ones are which. After you print these variables, please pass all four variables to a static method that you will create below. After you finish the method, please print out the four variables again: a, b, c, and d. Just as they were printed before the method.
Static methods: This method can be called whatever you want, however it will be public, static, and void. This method should take in four parameters: w and x which will be integers, then y and z which will be Account Objects.The first thing this method should do is to print out the four variables w, x, y, and z. This should be done in the same manner as you did in the main method. Next, change the first variable (w) to 15. After that, ted bought a new car. He now has only $20,000 in his account. Change the balance of y to be 20,000. Step three is to make a new Account Object named John, he has a balance of $10,000. Assign him to the variable z. Lastly, print all four variables again: w, x, y, and z.
View Replies
View Related
Feb 4, 2014
How to call web service from xml to java. I'm just new in using Java.
View Replies
View Related
Jan 22, 2015
We recently upgraded to JDK 8. Since then, a section of code in a jsp file breaks. The code is this:
ArrayList all = new ArrayList();
final List tsd = timeSeriesBean.getTSData();
all.addAll(tsd);
Collections.sort(all, new Comparator() {
public int compare(Object o1, Object o2) {
TSData t1 = (TSData)o1, t2 = (TSData)o2;
int res = t2.getDate().compareTo(t1.getDate());
[code]....
The error message is this:
An error occurred at line: 65 in the jsp file: /TS/VerifyImportTSData.jsp The type new Comparator(){} must implement the inherited abstract method Comparator.thenComparing(Function, Comparator)
64:
65: Collections.sort(all, new Comparator() {
66: public int compare(Object o1, Object o2) {
67: TSData t1 = (TSData)o1, t2 = (TSData)o2;
68: int res = t2.getDate().compareTo(t1.getDate());
just trying to maintain some old java code that I can support until it is rewritten.
View Replies
View Related
Sep 2, 2014
i want to use cucumber in java through code. previously i have used it with Junit. but now i need to implement it through coding for the purpose of automating.
View Replies
View Related
Feb 4, 2014
I have a new user on my website - it's password protected etc. and I'm just giving them the initial walkthrough. I have a java applet that plots charts and when he goes to this page he gets no chart and at the bottom of the pages there's a bar with the message "Internet Explorer blocked this website from installing an ActiveX control. What's the risk?" and then there's a button to say Install.
I said, it's just for you to permission running the java applet but his IT guy is saying that java doesn't trigger warnings about ActiveX controls so he's nixing the approval.
View Replies
View Related
Dec 10, 2014
I have to write Scanner and Parser for the C-Code based on Java and obtain Abstract syntax tree(AST) . I am allowed to use tools like ANTLR, CUP. But i should be able to expand all macros in my code to its basic low level data type like int, boolean and whats the best approach?How to start initially?
View Replies
View Related
Jan 22, 2014
I made just a simple hello world class and i can not seam to make eclipse run it in any way not even the console.
View Replies
View Related
Mar 29, 2014
In fact, I'm not yet past that "Hello World" program.I'm following the steps in "Head First: Java" book, and reached that point where one is ready to write his/her 1st Java code. Here's mine:
public class MyFirstApp
{
public static void main (String[] args)
{
System.out.println("I Rule!");
System.out.println("The World!");
}
}
As simple as it should be, and compiles fine producing the correspondent class. But it doesn't run, however, and spits the following execution-time errors:
Exception in thread "main" java.lang.UnsupportedClassVersionError: MyFirstApp : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
[code]...
View Replies
View Related
Mar 6, 2015
I need to access a method from a dll in java as below and is giving an error
"Exception in thread "main" java.lang.UnsatisfiedLinkError: Testdll.Decrypt(Ljava/lang/StringLjava/lang/String;
at Testdll.Decrypt(Native Method)
at Testdll.main(Testdll.java:31)
"
I have included the jna-4.0.0.jar and the HashMatchCryptography.dll to the project in eclipe and the java-library-path has the path for the lib
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Platform;
import com.sun.jna.*;
import java.lang.*;
[code]...
View Replies
View Related
Jul 25, 2014
How can we prevent SQL Injection in Java Code?..is there any Special cases..
View Replies
View Related
Mar 1, 2014
My method below works fine to print a matrix but when it prints every row, it is printing extra 4 white spaces which is not required. How can I delete those extra spaces at the end? when I use
System.out.print((matrix[i][j] + " ").replaceAll("^s+", ""));
It trims every thing including the spaces I needed for my matrix. So where should I put replaceAll("^s+", "") ?
Java Code:
private static void printMatrix(int[][] matrix) {
System.out.println();
System.out.println("Matrix:");
for (int i = 0; i < matrix.length; i++) {
for (int j = 0; j < matrix[i].length; j++) {
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
} mh_sh_highlight_all('java');
View Replies
View Related
Mar 7, 2014
Why can't I see the text when I compile the java code?
Java Code:
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.*;
public class WorldTravel {
public static void main (String[] args){
JFrame f = new JFrame("World Travel!");
BG_text p = new BG_text();
[Code] ....
View Replies
View Related
Apr 5, 2014
I have written a code to get all the nodes below a current Node and it is working but I need to get it to look better if possible. To get the number of nodes below I have created an Array List, which I then go to the first Node below and add all the people to the Array list on the same level till I get to the end of the level, then I go down again until I cannot go down any more. Is there a way I can have my code without having to use an array List? I have put my code below. The brieff about the tree is that you have a parent and below the Parent are children who can have brothers and sisters next to them and after that they also have children below that. The method is trying to find the number of children below any given child
private LinkedList<Node> TempQueue = new LinkedList<Node>();
public int noOfYoungerChildren(Member p1){
Node tmp = find(p1);
return countYoungerChildren(tmp);
[code]....
View Replies
View Related
Nov 24, 2014
I got a very simple code:
InputStream inputStream = null;
OutputStream outputStream = null;
try {
URL url = new URL(imgfm);
inputStream = url.openStream();
outputStream = new FileOutputStream(imgto);
byte[] buffer = new byte[2048];
int length;
[Code] ....
I have several pic to download (e.g 30) however, the code work for some pic (workable for a random number of pic, sometimes workable for 10 pics but sometime can only download 1 pics).
I try to input several println code to found out the problem. finally i found that all the code stop (it's stop as when i use debug process in eclipse, it get no respond) and the final appear code under console is:
2048
Start abc/testing.jpg
Finished
2048
Start abc/testing.jpg
Finished
2048
Start abc/testing.jpg
Finished
1935
Start abc/testing.jpg
Finished
It cant even go to "System.out.println("Can come to here!");"
View Replies
View Related
Feb 19, 2014
I am working on project "Abstraction of UML diagrams from java code". I am searching for a at least few codes to create class, object, sequence, activity, usecase diagrams.
View Replies
View Related
Nov 5, 2014
I want to write code in java to scan documents.
View Replies
View Related
Dec 30, 2014
I am running java 1.8 under 64 bit windows 7, using the code below I failed to log in, I am getting the log in page but not being logged in.
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
[Code] .....
View Replies
View Related
Feb 21, 2014
Following code I use to run or Launch another application
try {
Runtime.getRuntime().exec("rundll32 url.dll, FileProtocolHandler " + "Path of Application's EXE File");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e, null, JOptionPane.ERROR_MESSAGE);
}
if the above code is to launch another application using java then how can I close/exit the same(another) application using java code once I press the exit button of my java app.
View Replies
View Related
Apr 21, 2015
I am trying to figure out how to simulate an ability score calculation for an RPG character creation. The way I want to do it is to have 5 d6 dice rolled and then the best three of the 5 rolls are added together for a maximum of 18 points and a minimum of 3 points.
Now I know how to generate random numbers, but I do not know how to have the best 3 picked out. What I have right now is super simple.
package javaapplication12;
import java.util.Random;
public class JavaApplication12 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
[Code] ....
So this gives me my five rolls but then have the code pick out the best three every time the program is run is kind of an issue for me.
View Replies
View Related
Jul 13, 2014
I have a java project in Eclipse. I make changes to this project from different computers. I think this is a good opportunity to learn and practice some source control. Is there a source control system which will allow me to do this very easily ? How about Git ? Any outline of the main steps needed to setup this thing with Git, preferably within eclipse itself ? I don't need each and every step to prepare the whole system. I only need the main steps like - download and install git on both machines, rent a server and create a repo on it, grant both computers access to the server etc.
View Replies
View Related