Math Equation Game - Making Answer As Question

Apr 26, 2014

I want make a math equation game. usually math game use equation for the question and we answer that equation. ex : what is the result of 2*5 / 2+2/ 2^2 etc. and we answering that. but i want to make it different so i want to make the equation answer as the question and the equation as the answer of the game. Ex : the question is 54 so we can answer it with 9*6 or 24+30. and this is my java code

package coba;
import java.util.Scanner;
public class Coba {

public static void main(String[] args) {
double angka = Math.random()*70;

[Code] ....

but when i run it the error code show like this : Quote

View Replies


ADVERTISEMENT

Vector Math - Calculate Equation Of A Plane That Would Rely On All Axis

Jan 27, 2014

I am running into some trouble with Line-Plane intersection, my method works, provided I am perpendicular to the plane I want to intersect. This is caused be the plane equation (with my given x, y, and z coordinates, the equation is -Z - 1 = 0). So the equation is only relying on the Z value of anything inputted. Is there another way to calculate the equation of a plane that would rely on all axis? Here is my current code:

Java Code:

Vector3f A = new Vector3f(0, 0, -1);
Vector3f B = new Vector3f(0, 1, -1);
Vector3f C = new Vector3f(1, 1, -1);

Vector3f v1 = new Vector3f(B.x - A.x, B.y - A.y, B.z - A.z);
Vector3f v2 = new Vector3f(C.x - A.x, C.y - A.y, C.z - A.z);

float[] i = new float[]{v1.x, v2.x};
float[] j = new float[]{v1.y, v2.y};
float[] k = new float[]{v1.z, v2.z};

[Code] ....

View Replies View Related

Open Answer Quiz Game Using Java

Nov 1, 2014

I want to design an open-answer quiz game using Java. Basically, the plan is to design a quiz where the name of a medicine is displayed as "the question" and the player will need to input the unique code (as "the answer") of the medicine in an open box (all the codes are two characters). The list has about 204 named medicine (with potentially more to be included at a later stage). The questions will not appear in the same order for each session restarted; they will appear randomly.

The player will have 60 seconds, and for each correct answer, will score 1 point and add 2 seconds to the timer. The player will also have 6 "lives", and for each incorrect answer, the player will lose a life, with no effect on the time.

The idea of the game is that the player memorise as many of these medicine codes as possible.

View Replies View Related

Design Open Answer Quiz Game

Oct 31, 2014

I want to design an open-answer quiz game using Java. Basically, the plan is to design a quiz where the name of a medicine is displayed as "the question" and the player will need to input the unique code (as "the answer") of the medicine in an open box (all the codes are two characters). The list has about 204 named medicine (with potentially more to be included at a later stage). The questions will not appear in the same order for each session restarted; they will appear randomly.

The player will have 60 seconds, and for each correct answer, will score 1 point and add 2 seconds to the timer. The player will also have 6 "lives", and for each incorrect answer, the player will lose a life, with no effect on the time.The idea of the game is to support the player memorise as many of these medicine codes as possible. How this can be achieved from total grassroots.

View Replies View Related

Guess Number Game - Reveals Answer If User Input Is Wrong

Sep 1, 2014

The problem occurs after the user inputs the guess.... it either runs the for loop if guess = numtoguess and reveals the answer even if the user input is wrong.... or it always runs the first if statement in the while loop if guess!= to numtoguess... heres the code

public static void main(String[] args) {
String[] Answers = {"yes", "Yes", "No", "no"};
String Name = JOptionPane.showInputDialog(null, "Hello, What is your name?","Random Game", JOptionPane.QUESTION_MESSAGE);
String UI = JOptionPane.showInputDialog(null, Name + " do you want to play a game", "Random Game", JOptionPane.QUESTION_MESSAGE);

[Code] ....

View Replies View Related

Making Counter AI For Connect 4 Game?

Apr 28, 2015

I am a student in an intro to computer science class working on my final project. This is essentially a game of connect 4, but only requiring 3-in-a-row for victory. We were given the base game and a sample file to work with to make an AI that beats our professor's ai in the base game. Here is the base game

package cs110.project3;
 import javafx.application.Application;
import javafx.application.Platform;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;

[code].....

View Replies View Related

Making A Window For Java Text Based Game

Jan 10, 2015

So, Iv'e been trying to make a simple Text Based RPG with Java, and it is going quite well, and my friends want to play it too but they aren't very tech savvy, so it's hard to tell them to get an IDE or use the CMD, so I wanted to know if there was a way to make my text-based game into a window, like using JFrame or something. All i need is a window that displays the text, and a bar on the bottom that lets the user input what they want (Kind of like a CMD).

I want it sort of like this window: This Pic

View Replies View Related

Java - Compute PI Using Equation

Oct 24, 2014

Part 1: USING A WHILE OR A DO-WHILE LOOP write a program to compute PI using the following equation:

PI = 3 + 4/(2*3*4) - 4/(4*5*6) + 4/(6*7*8) - 4/(8*9*10) + ...

Allow the user to specify the number of terms (5 terms are shown) to use in the computation. Each time around the loop only one extra term should be added to the estimate for PI.

Alter your solution from part one so that the user is allowed to specify the precision required between 1 and 8 digits (i.e. the number of digits which are correct; e.g. to 5 digits PI is 3.14159), rather than the number of terms. The condition on the loop should be altered so that it continues until the required precision is obtained. Note that you need only submit this second version of the program (assuming you have it working).

My output for part 1 is :

Enter number of wanted terms for value of PI
100
PI = 3.1666666666666665 Number of Term = 2
PI = 3.1333333333333333 Number of Term = 3
PI = 3.145238095238095 Number of Term = 4
PI = 3.1396825396825396 Number of Term = 5
PI = 3.1427128427128426 Number of Term = 6
PI = 3.1408813408813407 Number of Term = 7
PI = 3.142071817071817 Number of Term = 8
PI = 3.1412548236077646 Number of Term = 9
PI = 3.141839618929402 Number of Term = 10 ................ and so on

I know you have to compare value of current Pi to the previous one but I'm stuck.

View Replies View Related

Completing Mathematical Equation In JavaScript

Jan 29, 2015

This first part of code is my HTML

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta charset="UTF-8">
<link href="jquery/jquery.mobile-1.4.5.min.css" rel="stylesheet" type="text/css"/>
<meta name="viewport" content="width=device-width, initial-scale=1">

[Code] .....

View Replies View Related

Difference From One Equation Is Being Added To Total Of Another

Jan 21, 2015

I am writing a program for finding the profit made after paying the broker. here is my code, I am wondering why Java

Code: paidBroker = commission + commissionAfterSale; mh_sh_highlight_all('java');

is being added to

Java Code: noProfit = profit - paidBroker; mh_sh_highlight_all('java');

Here is my full program, you can find these lines of code on lines 64 and 70.

Java Code:

import java.util.Scanner;
public class StockTransaction {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Variable Declaration Section

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Drawing A Semicircle Using Formula For The Equation Of A Circle

Sep 19, 2014

So Ive got to make a turtle on an image draw a semicircle that starts at the top of a circle and goes down and to the left, changing colors halfway through. I've got everything down, I can draw the turtles and make them do straight lines. My problem is more math related. I need to use the equation of a circle, give it points, and figure out how to write that code in java.

We use the equation for a circle: (x - a)^2 + (y - b)^2 = r^2

amanda.setName("amanda");
amanda.setShellColor(Color.BLUE);
amanda.setBodyColor(Color.RED);
amanda.setPenColor(Color.YELLOW);
amanda.setPenWidth(3);
amanda.forward();
amanda.turn(-90);
amanda.setPenColor(Color.BLUE);
amanda.forward(???);

the question marks are where I need to draw a line on an arc, like in the picture.

View Replies View Related

Java Objects And Classes - System Of Linear Equation

Mar 15, 2015

The question states: Design a class named LinearEquation

for a 2 x 2 system of linear equations:

ax + by = e

cx + dy = f

Where

x =

ed − bf/ad − bc

y =

af − ec/ad − bc

The class contains:

- Private data fields a, b, c, d, e, and f.
- A constructor with the arguments for a, b, c, d, e, and f.
- Six get methods for a, b, c, d, e, and f.
- A method named isSolvable() that returns true if ad−bc is not 0.
- Methods getX() and getY() that return the solution for the equation.

Write a test program that prompts the user to enter a, b, c, d, e, and f and displays the result. If ad − bc is 0, report that "The equation has no solution."

I believe that my program is correct because I am able to compile it and get no errors, however I have no clue how to display the information for x and y or display this equation has no solution if ad-bc=0.

Java Code:

import java.util.Scanner;
public class Exer911 {
public static void main(String[] args){
// Create a scanner system to hold the numbers for each variable
Scanner input = new Scanner(System.in);
// Prompt the user to enter a number for each of the variables

[Code] ....

How to get the information to display ....

View Replies View Related

Create A Program To Calculate Roots For 2 Degree Equation

Oct 14, 2014

I just created a program to calculate the roots for a 2. degree equation, When I first created my program, I defined the r1 and r2 as double, but got an error saying they needed to be defined as String, why is that?When should I be using string? I am new to java and I have mostly only used int, double and Boolean so far.

import java.util.Scanner;
import java.text.DecimalFormat;
public class c3e1 {
public static void main(String[]args){

[code]....

View Replies View Related

How To Assign Numbers Obtain From Modular Equation To Certain Position In Array

Apr 16, 2015

My biggest issues are as follows:

1) I'm trying to use a logarithm to determine the length of a user input number. I keep getting an error stating <> indetifier expected. I'm assuming this means that the program is not recognizing the function of a logarithm. I know that normally you can include that information in the method, but my teacher has stated specifically that each of these methods be called something else, as shown in the code.

2) I'm not quite sure I understand how to assign the numbers I obtain from the modular equation to a certain position in the array. As I'm asking the user to input any number these values can change so therefore I can't simply state that first number = this place.Here is my code:

import javax.swing.*;
import javax.*;
public class getSize
{
public static void main( String[] args )

[code]...

View Replies View Related

Getting Right Answer In While-loop

Jan 29, 2015

If I for example choose 8 as "multiplikationstabell" and 4 as "faktor" the whole code works except that "svar" gets printed as 8 in every turn. Why? "Faktor" gets added with 1 every time but "svar" stays at 8.......

import java.util.Scanner;
 public class Multiplikationstabell {
 public static void main(String args[]){
 Scanner Heltal = new Scanner(System.in);

[Code] .....

View Replies View Related

Solver For System Of Linear Equation In Java For Large Matrices (finite Element Program)

Jan 16, 2014

I develop a finite element code at java. I am looking for efficiency solver and fast for large, sparse , symmetric and positive define matrices .

i used in jblas but i encounter in problem when the matrix has high condition number(ill condition number) and i get error for singular matrix while in mathematica i succeed to solve that system without problems...

Any good solver and fast solver package in java can i use for solving that system?

View Replies View Related

Get Answer To Only Show Two Decimals

May 25, 2014

I have tried as much as I can to place code to give me only two decimals in answers but cannot get it to work not sure if placement or syntax.This is code so far and it works but gives answers to 8 decimals.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

[code]...

View Replies View Related

How To Use Asterisk Symbol For Answer

Oct 13, 2014

I am new to programing and I am making a dice game where I have to roll two dice and add the total together for each dice (2, 3, 4 ect.) I have all the program finished except one thing.

How would I use the * character that shows the total percentage each number was rolled. Each * will represent 1% of the total rolls. Instead of saying there were ( 4 ) 2's rolled i have to put ( **** ) 2's rolled.

2: ***
3: ******
4: *********

View Replies View Related

How Does Prefix And Postfix Change The Answer

Mar 26, 2015

Will the postfix x++ and the prefix --y change the answer for this question?

If x has the value 10 and so does y, then what is the value of (x ++) * (-- y)?

Answer: 11*9

View Replies View Related

How To Restart Program Once Answer Has Been Found

Oct 29, 2014

I am creating a body mass index calculator and i was wondering how i could make its so that the program resets itself once the BMI has been found....

My code is below...

package bmiCalculatorSource;
import java.util.Scanner;
public class BMICalculator {
public static void main(String[] args) {
final double KilogramsPerPound = 0.453;
final double MetersPerInch = 0.026;

[Code] ....

View Replies View Related

Put Answer Of JCheckBox Inside Of JTextArea

Sep 17, 2014

I would like to put the answer of JCheckBox inside of a JTextArea. How to call the answer of JCheckBox if its check the response should be Yes if its unchecked the response should be No, and the yes/no answer should be appear inside JTextArea. But my problem is inside the JTextArea the answer from a JTextField and JComboBox is also there, and they should be appear in a parallel. I attached the physical appearance of the GUI.

Attached image(s)

View Replies View Related

Calculating Sin(x) Without Using Math

Sep 14, 2014

I'm trying to calculate sin(x) without using Math.sin(x). The formula for sin(x) is: x - x^3/3! + x^5/5! ... I can't seem to get the coding for the alternating +/- right. Here's my program:

import java.util.Scanner;
import java.lang.Math;
class Sin
{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
int n, c, fact = 1, count = 1;
double x, sum = 0, sum_sin = 0, result;

[Code] ....

View Replies View Related

Formatting User Answer To Two Decimal Places

Nov 20, 2014

I am writing a simple learning program that does basic math. Everything is working as needed except for when it comes to division. I need to know if there is a way to format the users input to two decimal places and that when the program checks the users answer against the division, it gives it a yay or nay. Right now, it wants the answer out to 12 decimal places.

So for 5/3

I would like it to accept the answer 1.67

not 1.666666666667

Is there a way to do this?

View Replies View Related

How To Make Answer To 2 Decimal Points In Java

Jan 18, 2015

I am having trouble figuring out where to put %.2f in my code. I need it to get my answers for surfaceArea and Volume to be rounded to two decimal points. I have everything completed but wherever i put it, it seems to not work.

System.out.println("This program will compute the volume and surface area of a rectangular prism.");
String output;
double length;
double width;
double height;
double volume = 0;
double surfaceArea = 0;
System.out.printf("%.2f", surfaceArea);

[code]....

View Replies View Related

Fraction Calculator Prints Correct Answer But Not In Decimal

Feb 23, 2015

package FracCalc;
import java.util.Scanner;
public class FracCalc {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
 
int n1 = 0; //n1 = first numerator user have to enter
int d1 = 0; //d1 = first denominator user have to enter
int n2 = 0; //n2 = second numerator user have to enter
int d2 = 0; //d2 = second denominator user have to enter
int numeratorAnswer = 0; //calculates numerator of an equation
int denominatorAnswer = 0; //calculates denominator of an equation
 
[code]...

I mean its not that important but i figure it will be better if I could print out the answer both in fraction format and decimal format. while my answer prints in fraction just fine how do i show it in decimal?

System.out.println("");
 
System.out.print("And ");
System.out.print("answer in Decimal is: ");
 
decimalAnswer = ((double)numeratorAnswer/denominatorAnswer);
System.out.println((float)decimalAnswer);

View Replies View Related

True / False Result Cannot Be Printed Due To Variable Answer

Jun 30, 2014

Code in the book is written exactly like this:

import java.util.Scanner;
public class AdditionQuiz {
public static void main (String[] args){

//Generate random two integers using utility System.currentTimeMillis
int n1 = (int)(System.currentTimeMillis() % 10);
int n2 = (int)(System.currentTimeMillis() / 7 % 10);

[Code] ....

however the true/false result can not be printed due to the "answer" variable...

View Replies View Related







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