I have to write a program the calculates the MPG and display's the result on the screen. However, I have three errors I just can't seem to figure out. jGrasp points to the following error, but doesn't tell me what it is:
Programming Challenge #9.java:34: error: cannot find symbol
gallons = keyboard.nextInt();
^
symbol: variable keyboard
location: class MPG
3 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
My code is as follows:
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
// This program has variable of several of the integer types.
public class MPG {
public static void main(String[] args) {
Pretty much what im trying to accomplish, i need to write a program that figures out the distance between one point to another, using miles and feet..
Heres how it has to look: "The distance from my uncles house is ___ miles, or ____ feet."
I can get it to run if i add only whole miles..but when i try to add 8.5 miles, and compile, the program flips out..I know i need to use a double somewhere, but cant figure it out, here is my code..
import java.util.Scanner; //required for input public class feetToMiles { public static void main (String[] args){ //Create new scanner object called input Scanner input = new Scanner (System.in); //allows for input
Note: use for loop and printf() to format your output
public class MilesandKilometers { public static void main(String[] args) { System.out.println("Miles Kilometers"); int miles = 1 ; for (int i = 1; i <= 10; miles++, i++) { System.out.println(miles + " " + miles * 1.609); } } }
how to make it like the instruction said " use for loop and printf() to format your output".
I'm doing to create miles/kilometers converter. If I put the mile, converting to kilometer is right. However, if I put the kilometer, converting to mile comes out wrong value. Which part is wrong?
I have made a program which finds the number of occurrence of the words. It is as follows :
public class B { public static void main(String[] args) { Map<String, Integer> mp = new LinkedHashMap<String, Integer>(); String s = "This is me tarun ohri This"; Scanner p = new Scanner(s); int i = 0;
[Code] .....
Output is coming {This=0, is=1, me=1, tarun=1, ohri=1}
I have to write a program that find the sum of two numbers 62 and 99 and stores them in a variable named total. However, I have one error that I just can't get rid of and can't tell what it is. I'm using jGrasp and here's what it says:
Programming Challenge #5.java:14: error: class SumofTwoNumbs is public, should be declared in a file named SumofTwoNumbs.java public class SumofTwoNumbs { ^ 1 error ----jGRASP wedge2: exit code for process is 1. ----jGRASP: operation complete.
and here: is my code:
import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** // This program has variable of several of the integer types. public class SumofTwoNumbs { public static void main(String[] args) {
I wrote a program that find adjacent value for -1 .ex:
input 1 3 3 1 2 2 1 1 -1 5 5 0
output 1
code: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package javaapplication1; import java.util.Scanner;
im trying to do a program to find if numbers are consecutive or not! if they are consecutive i need a true as a return and a false when they are not... i did this program and im sure i did something wrong because i keep only true returns ..
Example: (3,5,7) (1,2,2) (7,7,9) should return a false! Java Code: import java.util.*; public class Consecutive{ public static void main (String [] args){ Scanner console= new Scanner(System.in); System.out.println("Enter three numbers"); String numbers = console.nextLine(); System.out.println( "The numbers (" + numbers + ") is '" + consecutive( numbers ) + "'" ); }//end of main
I finished a game in Java and sent it to a friend. Launching the program in my computer worked just fine.
But he got this error : "Could not find the main classs: Main. program will exit"
My JRE version is the most updated one. His JRE was version 1.6. He updated his JRE, and the problem was solved.
This is a bit worrying for me, because as far as I know, 1.6 isn't a very old version of the JRE. It's not the most recent one, but not that old.
This is worrying because I'm planning on sending my game to a lot of friends, and trying to distribute it on the internet.
A lot of people don't have the most updated JRE. And they are mostly non-programmers, so I can't expect them to update to the newest version of Java upon downloading my game. They might not know what Java is, even though they got it on their computer, and upon receiving an error, they'll just give up on the game.
If my game wouldn't work with a significantly old JRE, that would be reasonable. It's part of the nature of working with Java. But the fact that a relatively updated JRE, 1.6, doesn't work with my game, is worrying.
*(Please note: My game isn't implementing anything "special". Swing and KeyBindings are the 'newest' additions to Java that I can think of inside my game)*.
In short, I'd like to know that my game works on most of the computers it tries to run on. Knowing that it doesn't work on a relatively new JRE, is worrying.
So I have two questions:
1. Is it normal, for a Java program, to have such "high" demands for the JRE version? Do a lot of Java games demand at least version 1.6 of the JRE? Is this common?
2. How can I find out the minimum JRE version requirement for my program? Is there a methodical way to do this, or do I just have to go through all the libraries I use in my game and figure out what's the JRE release version for each one?
I just created a Hello World program in Notepad, but command prompt still can't find it even when ran as administrator. I've even tried to use command line to run Hello World programs I've created with Eclipse but it still doesn't work. Here's proof I have JDK setup as PATH:
I've even tried having the JRE as path but that still doesn't solve my problem. I'm really trying to learn Java programming but this problem is holding me back.
I'm required to create a program that finds the minimum value in an Array of integers.
Here is my approach :
public class Person { public static void main(String [ ] args){ int theArray[]=new int [10]; int result = 0; for (int i:theArray){ if (i < Integer.MAX_VALUE)
[Code]...
I can't really progress from this position. I keep getting told to change the return type to int on main method, then when i do it says change it to void..
I can't get the code to compile for the driver every time i get an error message saying
SudokuCheckerTest.java:28: error: cannot find symbol foo.displayGrid(grid); ^ symbol: variable grid location: class SudokuCheckerTest SudokuCheckerTest.java:29: error: cannot find symbol foo.getGrid(grid);
[Code] .....
4 errors
Java Code :
import java.util.Scanner; public class SudokuChecker{ public SudokuChecker(){ // displays intro code and initializes the array grid as well as using method calls. Scanner in = new Scanner(System.in); int [][] grid = new int [4][4]; displayGrid(grid);
This is my first java program,i am using eclipse IDE-----
package day1.example;
public class MyFirstJava {
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("hi"); } }
When i saved it,it shows no error.when i run it then a pop-up says "could not find the main class.the program will exit" and in the console it says---
java.lang.UnsupportedClassVersionError: day1/example/MyFirstJava : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$000(Unknown Source)
I want to find the prime palindrome numbers less that a given number by my program. Here is my code, I am trying to find the method to solve the errors when I compile it. It said variable a might not have been initialized in line 41,62,86.
import java.util.Scanner; public class Lab5{ public static void main (String[] args){ System.out.println("Please input a number"); Scanner Input=new Scanner(System.in); int num = Input.nextInt();
I need to write a java program to find the index of the element whose value is the sum of the remaining elements. Recently I have been asked this question in an Interview which I couldnt solve properly.
Write a program that prompts the user to enter an integer m and find the smallest integer n such that m * n is a perfect square. (Hint: Store all smallest factors of m into an array list. n is the product of the factors that appear an odd number of times in the array list. For example, consider m = 90, store the factors 2, 3, 3, 5 in an array list. 2 and 5 appear an odd number of time in the array list. So, n is 10.)
so far my program is just like this.
import java.lang.Math; import java.util.Scanner; public class PerfectSquare { public static void main(String[] args) { Scanner m = new Scanner(System.in); int Fint;
[Code] .....
how do i make the program find the smallest integer n?
I am writing a payroll program .The program generates random PPS numbers and then takes in users information and calculates the salary accordingly. I am using netbeans and my code is showing errors on line 18 and 42 ("cannot find symbol")on the code for grossPay(). The program seems to crash after a new PPS number is generated and will not run.
package sd_assg_2; import java.util.Arrays; import java.util.Random; import javax.swing.JOptionPane; public class SD_ASSG_2 { public static void main(String[] args) { String[] newPPs = getPPSno();
Have written a program to open Excel sheet from java program.Below line works fine.
Process p = Runtime.getRuntime().exec(new String[]{""C:Program Files (x86)Microsoft OfficeOffice12Excel.EXE"","C:UsersRASHPA~ 1.ORAAppDataLocalTempExport_xl420314062726 9379706.xls"});
But below code gives error i.e. Executable name has embedded quote, split the arguments