So I should use String instead of chars, right??
--- Update ---
I have changed my code and it shows the right answer, but the output shows like a few Errors before the answer:
Error
Error...
Type: Posts; User: Daler
So I should use String instead of chars, right??
--- Update ---
I have changed my code and it shows the right answer, but the output shows like a few Errors before the answer:
Error
Error...
Hey guys,
Here is the question: Design Java code to find and return the frequency of string b in string a.
For example , if string a = "abcdabcfabxyabd" and string b = "ab"
The frequency...
Thanks for very clear algorithm. The answer is correct when I don't put factorial "!" into my calculator(18.07950938), but when I put "!" in the calculator it gives me a different answer with the...
Yes, sir. I've tried it too, but it doesn't give the right answer either. I can't quite understand whether I should add something else to it.
Sorry.
Hey guys,
I have a little problem here. The program runs and everything is fine except the actual result. The question is:
Design Java code to calculate and print ∑ (n! + 5) / (n+1)! ; n is an...
Can anybody explain me why javapenguin ws banned?
Thank you for help javapenguin and Norm! I really appreciate it... I learn a lot from both of you guys.
That's awesome, look at the output:
[java=code]
Enter how many random numbers you want to generate
100
0. ***********
1. *************
2. ********
3. ****
4. *********
Now I don't see any mistakes, except after I enter the numbers
[java=code]freq [k]++; // it shows mistake here[/code]
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -5...
Yes! I changed it to
int freq = (int) (Math.random() * 10);
import java.util.*;
public class xyz
{
//Don't you mind to show me how to fix this?
//the last line was just a comment
Norm,
int [] freq = (int) (Math.random() * 10); // cannot convert from int[] to int
this is the only mistake.. is it possible to fix this??
import java.util.*;
public class xyz
{
public static void main(String [] args)
{
Scanner S=new Scanner(System.in);
System.out.println("Enter how...
It doesn't show any mistake before I launch it, but after I've entered the number I wanted to generate, it showed me this mistake
Exception in thread "main"...
Alright! Here is my code:
import java.util.*;
public class Shapes
{
public static void main(String [] args)
{
Scanner S=new Scanner(System.in);
What does this mistake mean:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException… -3
at pratice.main(pratice.java:16)
it should work now.. I don't know why it does appear that...
Thanks a lot for your help! I have already written the program and it actually worked.. I used the DecimalFormat class as you said before!
Thanks a lot! I really appreciate it...
So how to make...
so if I will use arrays, it should look like this?
import java.util.Scanner;
public class shapes
{
public static void main (String [] args)
{
Scanner scan = new Scanner(System.in);
I am not really sure about arrays. We didn't cover the topics about arrays though. Can you tell me more about it?
In the first loop we just put like
for(double num= Math.random(); num <= 10;...
Ok! I will try, but if I am wrong, sorry...
1. Understand what the program is supposed to do. ( I understand, but not so clearly as I should)
2. Initialize and declare the variables(I should...
what about double num = Math,random(); do I have to use it before loop?
but what about double num = Math,random() ? Where do I have to use it?
Am I right using "while" instead of "for"? Sorry, I am just new to programming...
So I have to use if-else ?
I got it, but for example if you wrote 100 as an input, how do the program knows how many *s are needed? How to make *s instead of just random numbers??