System Prints Final Statistics Many Times

May 25, 2014

I made a heads or tails game but I'm getting a bug when the user says he doesn't want to play anymore. The statistics are printed as many times as the games played. If you want to test the code, write" cap" " pajura" and when the program says "Vrei sa mai joci?" that means "do you wanna play another one?" and you can answer with "da"(yes) or "nu"(nu) Here is the code:

import java.util.Scanner;
public class cap_sau_pajura{
private static int user;
private static int pc;
private static String converted;
static int usermove;
private static int castiguri = 0;
private static int pierderi = 0;

[code]....

View Replies


ADVERTISEMENT

Grading Program - Calculate Final Grade By Using Weighted Scoring System

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

Creating Final Arrays With Final Elements

Aug 2, 2013

I want to create a final array with final elements
 
{code}
final int[] array = {0, 1, 2, 3, 4, 5};
{code}
 
But here only the reference of the array is final , not it's elements ... So how can I do that??

View Replies View Related

EJB / EE :: Inquire To Get Some Queue Statistics Like Current And Max Depth

Apr 7, 2014

In weblogic deployment, I have my MQ profile defined which creates weblogic.jms.PooledConnectionFactory. I want to Inquire to get some queue statistics like Current depth and max depth. If I have MQQueueConnectionFactory/MQQueueManager, I can do this with MQQueue INQUIRE but I am not able to find a solution for this from PooledConnectionFactory.

Is there a way to convert PooledConnectionFactory to MQQueueManager/MQQueueConnectionFactory or is there any other way to INQUIRE from PooledConnectionFactory.

View Replies View Related

Why Constructor Cannot Be Final

Oct 27, 2014

"A constructor cannot be abstract, static, final, native, or synchronized."

I understand on why it can't be all of the above, except "final".

Why can't we have a final constructor, i understand constructors are not inherited, hence no chance/case of overriding etc. But why is it not allowed at all ?

View Replies View Related

Prints Every Minimum In Array

Jan 20, 2015

The second message dialog result is always 0 ... i want to find the minimum grade...

import javax.swing.*;
import java.util.Arrays;
public class Parrarrapapa{
public static void main (String[]args){
String length = JOptionPane.showInputDialog("Number of students");

[code]....

View Replies View Related

Array Prints Out Zeros?

Nov 16, 2014

Ok, so let's say I am having a user input scores and at the end I want to print out the results so I do something like:

int[] Scores = new int[1000];
//code to ask user for input and store into array //

The user only inputs lets say 5 scores out of possible 1000. I then try to print it out by doing something like this:

for(int counter = 0; counter < Scores.length; ++counter) {
System.out.println(Scores[counter])
}

How would I go about printing out only the index's that were input, because right now it prints out the scores and then 995 0's after.

View Replies View Related

PrintWriter Only Prints Last Line?

Dec 6, 2014

I'm tyring to print the same output in console to a text file, but I can only get the last line of the console output in the text file, not sure what is wrong with my code:

while (in.hasNextLine()) {
PrintWriter writer = new PrintWriter("output5.txt");
tempS = in.nextLine().toLowerCase();
System.out.println(wp.bestPages(tempS));

[code]....

What's causing only the last time to be printed in text file? Are there better ways to print console outputs into a text file than PrintWriter?

View Replies View Related

Program Prints 2 Values Instead Of One

Feb 4, 2015

When I run this code, it is supposed to get one value from turnTimer(); and return it, just as a test. This works when I enter a valid pit. For example. If I were to input "A" when it's player one's turn, it will return 1, like it should. However, if I were to type "H" when it's player one's turn, it returns "Not a valid pit!"(like it should) but then it also returns 12. It shouldn't know that H is 12 because it's in a separate method. I'm confused as to why it's printing both values.

import java.util.*;
public class Mancala {
static Scanner input = new Scanner(System.in);
public static int pit;
public static void main(String[]args) {
Mancala mancala = new Mancala();
int[] board = {0,3,3,3,3,3,3,0,3,3,3,3,3,3};

[Code] .....

View Replies View Related

Deleting From ArrayList / Goes Through Both If And Else And Prints

Dec 8, 2014

I've a ArrayList with dogs on, and I've a function that should allow me to delete a dog from the register and if the dog was found it prints "The dog was deleted" and if the dog doesn't exist in the arraylist it should print "the dog couldn't be found".

Everything works perfect until I shall delete a dog that is not first on the list. Then the program shows first "dog was not found" and on the row after "the dog was deleted" if the dog was second on the list. If it was third I will get 2 messages that the dog wasn't found and then that the dog was deleted. I've no clue why it prints both else and if!

public static void taBortHund(){
//Har tar vi bort hund fran listan
//System.out.println(hundlista);
System.out.print("Vilken hund vill du ta bort? ");
String hunden = tangentbord.nextLine();
for (int taBort = 0; taBort<hundlista.size(); taBort++){

[code]....

View Replies View Related

Final And Static Method?

Feb 7, 2014

My teacher has asked me one question that "What is difference between the final method and static method".

View Replies View Related

How To Make A Table That Prints Out Sin / Cos / Tan For Angles

Sep 30, 2014

I am stuck and having a problem trying to find what i believe is a simple fix but can't wrap my head around it. For class I needed to make a table that prints out Sin,Cos,Tan for angles in steps of 5 to 180. The problem is in my output with the first couple lines of the table. for angle 5.0 the Sin(.0872) Cos(.9962) and Tan (.0875) are being displayed on the angle line 10.0

public class TrigTable {
public static void main(String[] args) {
double angle = 0;
double sin =0;
double cos = 0;
double tan = 0;
 
System.out.println("Angle Sin Cos Tan"); // Table header for the values

[Code] ....

Here is the first couple lines of output:

Angle Sin Cos Tan
----- --- --- ---
0.0 0.0 1.0 0.0
5.0 0.0 1.0 0.0
10.0 0.0872 0.9962 0.0875
15.0 0.1736 0.9848 0.1763
20.0 0.2588 0.9659 0.2679

View Replies View Related

How To Use Logger And Prints Time And Date

Feb 5, 2015

I need to add Logger function in the catch block that prints time, date and description of the what had happened.

public class InputUtil {
public static final String[] SPECIAL_CHARACTERS = { "!", "#","%", "^", "=",
"+", ";", "[", "]", "|", "<", ">", "?", "~", "`", "-", "" };
public static String deleteSpecialCharacters(String inputString) {
String outputString = inputString;

[Code] ....

View Replies View Related

Program Prints 2 Values When It Should Only Print 1

Feb 4, 2015

When I run this code, it is supposed to get one value from turnTimer(); and return it, just as a test. This works when I enter a valid pit. For example. If I were to input "A" when it's player one's turn, it will return 1, like it should. However, if I were to type "H" when it's player one's turn, it returns "Not a valid pit!"(like it should) but then it also returns 12. It shouldn't know that H is 12 because it's in a separate method. I'm confused as to why it's printing both values.

import java.util.*;
public class Mancala
{
static Scanner input = new Scanner(System.in);
public static int pit;
public static void main(String[]args)
{
Mancala mancala = new Mancala();
int[] board = {0,3,3,3,3,3,3,0,3,3,3,3,3,3};

[code]....

View Replies View Related

Create Program That Prints Time Between 00:00 (0:00 Am) And 23:45 (11:45 Pm)

Feb 8, 2014

I was told to create a program that prints the time between 00:00 (0:00 a.m.) and 23:45 (11:45 p.m.) in the 24-hour clock and 12-hour clock format like this:

24-hour Clock 12-hour Clock
-----------------------------
00:00 0:00 a.m.
00:15 0:15 a.m.
00:30 0:30 a.m.
00:45 0:45 a.m.
01:00 1:00 a.m.
01:15 1:15 a.m.
01:30 1:30 a.m.
01:45 1:45 a.m.
02:00 2:00 a.m.

ect...

but cant seem to create the program and my program doesnt seem to run.

View Replies View Related

Write A Method That Prints Characters

May 7, 2014

Write a method that prints characters using the following: public static void printChars(char ch1, char ch2, int numberPerLine). This method prints the characters between ch1 and ch2 with specific numbers per line. Characters are separated by exactly one space.Test your method with the following main method:

public static void main(String[] args)
{
printChars(‘A’,’z’,10);
printChars(‘0’,’9’,5);
}

View Replies View Related

Why Are Final And Abstract Called As Modifiers

Feb 8, 2015

I just wanted to know that why are final and abstract called as modifiers ,what is the essence of calling them as modifiers since there are two types of modifiers access modifiers and non-access modifiers so final and abstract come under the second category ,so why are these called as modifiers?

View Replies View Related

Final Reference Variables In Java

Feb 28, 2015

I am unable to understand the meaning of this sentence "final reference variables must be initialized before the constructor completes.",What is trying to imply?

View Replies View Related

When Final Variable Occupy Memory

Sep 23, 2014

when final variable occupy memory in java?

View Replies View Related

Final Static Variables In GregorianCalendar

Oct 27, 2014

why using the get method(c.get(c.HOUR_OF_DAY)); gives me the correct hour(currently 19) but directly accesing c.HOUR_OF_DAY returns 11 ? It shows In the documentation that HOUR_OF_DAY is public.

import java.util.*;
public class calendar2 {
public static void main(String[] args) {
new calendar2().timer();
}
private void timer() {
Calendar c=Calendar.getInstance();
//c.clear();
System.out.println(c.get(c.HOUR_OF_DAY));
System.out.println(c.HOUR_OF_DAY);

}
}

View Replies View Related

How To Take Runtime Value For Static Final Variable

Jul 28, 2014

How can i take run time value for static final variable...my lecturer said first time assignment is possible for declared final variable but in my case it shows compile time error..I'm placing my program below with error message

class Sample
{
static final String cname;
void print() {
System.out.println(cname);
}
public static void main(String args[])
{
cname=args[0];
Sample s=new Sample();
s.print();
}
}

Sample.java:11: cannot assign a value to final variable cname.
cname=args[0];

View Replies View Related

Grade Input And Final Average

Sep 15, 2014

For this assignment you will be writing a grade book program. The program will work for one student. It will need to take as input the students name. The user will then be asked to input grades into three categories in this order:

1) homework;
2) quizzes;
3) tests.

The grades in a given category will be averaged to one number that is the average of all grades in that category. The final average will be the weighted average of each category, where homework is worth 25% quizzes are worth 25%, and test are worth 50%. Like this:

Homework Grades: 65, 70, 75, 80, 80 Homework Average: 74
Quiz Grades: 75, 80, 85, 80. Quiz Average: 80
Test Grades: 75, 80, 85, 75 Test Average: 78.75
Final Average = 0.25*HomeworkAvg + 0.25*QuizAvg + 0.50*TestAvg = 77.87

But i only have the average and i dont know how to move past that..

Heres my average code :

import java.util.Scanner;
public class Homework3 {
public static void main(String[] args) {
Scanner myScanner = new Scanner(System.in);
int gradeCount = 0;
int grades = 0;
int holder = 0;

[Code] .....

View Replies View Related

What Is The Impact Of Declaring A Method As Final

Nov 14, 2014

1 Can method declared as final be overridden and overloading ?

2 if A is static sub class of B. how to access a method in class A ?

View Replies View Related

Parsing Error With Final Bracket

May 8, 2014

Im working on a class to add to my final project but im getting a parsing error for the final bracket, i double checked to make sure im not missing any but im still getting an error

import java.util.Scanner;
public class totalprice
{
public static void main(String[] args)
{
scanner keyboard = new Scanner(System.in);
{
DecimalFormat num = new DecimalFormat("#.00");
char meal;
int ammount;
double cost;

[code]....

View Replies View Related

Where Are All Keywords Like Final And This Stored In Java

Jan 23, 2014

Which package or class i can find all the predefined keywords in java like "this" etc...

actually i want to know if this operator is itself final in nature or not from its syntax?

View Replies View Related

Accessing Variables - What Is The Final Value Of Counter

Mar 7, 2015

While reading head first java i encountered a problem(Pg. 90 chapter 4 - mixed messages).

Suppose in a class(say A) outside main() a counter variable is declared and initialized to 0.

In main() declared the array of objects of the class A.

Consider a while loop in which we increment the counter as follows:

public class A{
int counter = 0;
public static void main(String[] args){
A[] arr = new A[20];
int x = 0;
while(x<4){
arr[x] = new A(); //arr[] is array object
arr[x].counter += 1;
x++;
}
}
};

what is the final value of counter ? will it be the same for all array objects.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved