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;
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:
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.
"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 ?
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");
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?
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};
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++){
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
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};
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:
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); }
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?
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?
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);
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];
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;
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;
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.