I'm converting from ASP to Java for a legacy site. I believe the first part of the if statement is right but I'm having an issue within the else staetment. I'm getting date is undefined, I've tried using getYear and getDate but have not been successful.
ASP:
If Request("action") = "results" Then
aMonth = Request("selMonth")
aDate = cint(Request("selDate"))
aYear = cint(Request("selYear"))
Else
aMonth = UCase(MonthName(Month(Date()),true))
aDate = Day(DateAdd("d",-1,date()))
aYear = Year(Date())
End If
I compiled a java program and converted it to an exe file and it works fine on the computer I created the java file in but when i try it on another computer it gives me a "Java Virtual Machine Launcher - A Java Exception has occured" error message.
I am trying to use a for loop for getting hours for an employee for five days. how to convert my pesodocode into java language so that it will compile. This is what my pesodocode looks like:
begin getHours() for(index=0; index <5; index++) get hours **System.out.println() **inputString = input.readLine() **plumbersHours[index] = plumbersHours [index] = integer.parseint(inputString) endfor index = 0 while (index < 5) totalHours + = plumbersHours[index] index++ end while return
I am trying to Extract the ranges of Variables from a Text File. I extracted lines of the forms X in 1..10 Y in 12..50 Z in 0..19 / 66/ 95..100 Where X in 1 ..10 states that X takes values from set 1 to 10 Similarly for Y and for Z its a Union of different ranges of the values (0 to 19, union 66,union 95 to 100)
I want to Map these Variables to their respective sets using Hashmap where Key is Variable name and value will be a Set. My Hashmap Signature is HashMap> hm=new HashMap>();
how to use Java and for my coursework I have been asked to construct an application that will read in the exam mark and coursework mark and then print out to 1 decimal place the average of the coursework and exam mark. When I submit it to the coursework submission system it says it's incorrect.
The answer that it's asking for is the answer that my code produces (ex = 71 cw = 40 mark = 55.5) But for some reason it says this when I submit it:
-#### << Differences between expected (<) your answer (>) >> ------------ 1c1 < ex= 91 cw = 80 mark = 85.5 --- > ex = 71 cw = 40 mark = 55.5 -------------------------------------------------------------------------
Check the above output for why this attempt failed And when I change the ex to 91 and cw to 80 it asks for > ex = 71 cw = 40 mark = 55.5 again.
class Main { public static void main( String args[] ) { int ExamMark=71; int CourseworkMark=40; double cost = (double)(ExamMark + CourseworkMark) / 2; System.out.printf("ex = " + ExamMark + " cw = " + CourseworkMark + " mark = " + cost); System.out.println(); } }
I am trying to create a program that allows me to enter 5 students numeric grade (0-100) to a letter grade (A, B, C, D, F) and I CANNOT use an array. When I try to run my program it says main class not found, and when I change the it from a string to a void in the main method it does not work.
Java Code:
import java.util.Scanner; public class Week3ControlStatements2 { public static String main(String[] args){ int numberGrade = 0; int quotient = numberGrade / 10; int remainder = numberGrade % 10;
I am trying to write a program for converting positive binary inputs into hex. in the hex output the point (".")is missing.
Suppose my expected output is e7.6 , but i am getting e76
only the "." is missing.
here is my BinToHex class..
import java.io.*; public class BinToHex { double tempDec,fractionpart; long longofintpart,templongDec; String input ="11100111.011"; String hexOutput=null,tempDecString,hex = null; static int i = 1;
I'm very new to Java and looking to expand knowledge base from Excel VBA..I'm looking to add or analyse data from a csv file in a time order fashion. i.e i want to keep/ add a cumulative total. (once i've achieved that i then want to look at a java equivalent of sumif...
I try to use below codes to convert Hex String "1111737999630745" to ASCII.
When I read the result in Notepad++ with HEX-Editor plugin, I find attached image which is different from above String, there is one additional c2 and I am quite confused.
Java Code:
public static void main(String[] args) throws IOException { Test strToHex = new Test(); File file = new File("D:/filename"); // if file doesnt exists, then create it if (!file.exists()) { file.createNewFile();
I was reading about the char data type in Java. I know that an unsigned 16 bit integer is used to represent a char. So we can write the assignments below:
char a = 65; // a will get the value 'A'
But the limit of the char value is 65535.
So I've tried out a few things with char and trying to understand them but I'm not sure how they work.
char a =(char) 70000; char b = (char) -1;
In the first case I thought that 70000 % 65535 would happen internally and the unicode character present at that location would get stored in 'a' but if I do that I get the answer of 70000 % 65535 as 4465. But when I display 'a' it shows me the output as '?'. Clearly '?' isn't at 4465.
In the second case I have no clue what's happening but somehow when I display 'b' it shows me '?' again.
Here is my code, basically I'll tell you what my program is suppose to do, I want to be able to leave the text box's empty if I like I want to skip 1 or more or all if I like skipping just basically means 0 but getting this error, it's forcing me to type in them all.
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "" at java.lang.NumberFormatException.forInputString(Unk nown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at StockControl.addToStock(StockControl.java:86)
I have this project due and its asking that i print out what type of triangle it is when the user inputs 3 sides. I have most of it done and working, but it pops up different windows instead of using one window for everything. The assignment says it needs all the final info to be in one window. The boolean is coming from another method. I'm unsure how to get it into a string (Or if that's what i have to do). The method must return a boolean true/false.
import javax.swing.*; public class Triangle { public static void main(String[] args) { int side1 = getSides(); int side2 = getSides(); int side3 = getSides();
In my Java class, the last assignment we had to turn in was to create a program that would take a users input and create a new type of animal. I went through the different steps in the instructions, and everything seemed to be going well up until the point where we actually took the users input and created the new animal. Specifically, I kept getting an error stating that I could convert a String to an animal.
I'm attaching the main class (Animal), one of my animal classes (Bird) and the class where I'm getting the error (AnimalStuff). I turned the program in as is, so what's done is done, but I'd like to learn what I'm doing wrong and what I can do better. I do know that the loop in AnimalStuff is wrong as it doesn't work right either, but I'm more concerned about the conversion from String to animal, as the entire program depended on this to work, and it doesn't.
public class Animal { /** * @param args the command line arguments */ public static void main(String[] args) { } public static String kind; public static String integument;
[code]....
Is there anything that jumps out at to what I'm doing absolutely wrong?
I've started writing a new program that Scans for some strings. I want to specify a random Integer to those Strings in order to do my desired idea. what should I do?!! my codes are here :
import java.util.Random; import java.util.Scanner; public class Draw { public static void main(String[] args) { System.out.println("This Program is written to solve little problems in families cause of doing unwanted works!!");
[code].....
now I want to Specify an Integer to each person that has been scanned! for example if the first person is " David " , which is a String, in the next step :
Random randomNumber = new Random(); randomNumber.NextInt(101); int David = randomNumber.NextInt(101);
Technically, when you run the program, a gif page appears (that I put as a placeholder) and when you press the letter 'n' JCreator runs the program, displaying a character P on a .txt field made using the Notepad on Windows. You can move it left, right, down, and up andf it will move accordinly. However, each time I make such action, the compiler has to rewrite to whole .txt field with the new position.
My former tutor said that in order for it to be "real-time", we have to use an applet.
I'm trying to complete a code to convert decimal to octal. however i can't figure out how to print the output correctly. it should be.. Your integer number 160000 is 0470400 in octal. (160000 is the number you input). My code is...
Scanner input = new Scanner(System.in);
int value; int a; int b; int c; int d; int e; int f; int g; String result;
[Code] .....
Lastly, my output prints everything correctly, but the input number always is 0.
Ex error: input= 160000
Your integer number 0 is 0470400 in octal.
it should be.. Your integer number 160000 is 0470400 in octal.
I am taking Python this semester. Our teacher wants us to convert Python to JavaScript without really explaining how or/and expecting us to be familiar with it already.Python Program I have is pretty simple - it prompts you to enter your first and last name and end your DNA string, "CAG" repeats are counted by another function and the result is passed to function that identified weather you may have huntington's decease or not.
<body> <p>Enter First Name: <input type="text" size="25" id="firstname" value=""> <p>Enter Last Name: <input type="text" size="25" id="lastname" value=""> <p>Enter DNA: <input type="text" size="25" id="DNA" value="" > <p><button onclick="alertt(f,l,d,c,p)" style="background-color:pink"><b>PRESS TO FIND OUT RESULT</b></button></p> <script>
[code]...
When I run it there is an issue with countCAG and prediction functions :( I would run each one individually in JS console and I get Undefined, or InvalidString I read that I am supposed to use var in front of each variable, unlike in Python where you just assign variable a value without any add-ons in the front. But JS console seems to recognize both ways of assigning, however var smth=0 immediately evaluates to Undefined, and smth=0, gives me 0...
I am trying to display the contents of my Object but when I compile it I get this:proj4.TellerQueue@1db9742
I am pretty sure it's because I havent created my own toString method but I could be wrong. If this is the case, what do I need to do to properly display the variables of my object? Right now my class, BankQueue, contains another object called Person, which contains a String and int variables. I want to do something like this:
class BankQueue{ Queue<Person> q = new LinkedList<Person>(); public String toString(){ return q.;//display contents of the q
[code]...
but Im not sure how to convert these into Strings.
I'm new to coding and we have an assignment for class to convert fahrenheit to celsius so far this is what i have:
import java.util.Scanner; public class Lab5 { public static void main(String[] args) { //variable dec Scanner scan = new Scanner(System.in); double input;
[code]...
This is what he wants us to do "Write a method name celsius that accepts a Fahrenheit temperature as an argument. The method should return the temperature, converted to Celsius. Demonstrate the method by asking the user a temperature value to convert. Then below the result, call a loop that displays a table of the Fahrenheit temperatures 0 through 20 and their Celsius equivalents."