probably novice errors

###(extra context you dont actually need this) hello hello, ive gotta do some 20~ programs for my computer class but since im still fairly new to it and only learnt it surface level to get through last year I dont really get the proper workings of the language (like ik the basic vocab and grammar but my understanding of participles and tenses suck) sooo im gonna ask here if im facing any issues I legitimately do not know how to fix, even after a bit of google searching I absolutely do not expect anyone to do my stuff for me but some help would be appreciated thanks
72 Replies
JavaBot
JavaBot7mo ago
This post has been reserved for your question.
Hey @Piglet | NEED tone tags!!! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Piglet | tone tags would be nice
im getting a "class name required" error on this even thought the class is named and follows the naming rules
Piglet | tone tags would be nice
im hoping that got embedded cuz it doesnt look like it did on phone ohhh looks like it has to be a plain txt file so one sec
dan1st
dan1st7mo ago
it got embedded for me What exactly happens when running it
dan1st
dan1st7mo ago
Can you please fix the formatting? and that
Piglet | tone tags would be nice
I only get this
No description
dan1st
dan1st7mo ago
Writing code on your phone is usually a really bad idea
Piglet | tone tags would be nice
ik but ive got a week to get this over w and I wont be home till half of it is done 😭😭
dan1st
dan1st7mo ago
and your code is syntactically valid - including the class and the main
dan1st
dan1st7mo ago
How exactly are you running it with your phone?
Piglet | tone tags would be nice
JStudio - ide for java - Apps on Google Play
A java ide for developing android apps and java console programs.
dan1st
dan1st7mo ago
yes but what exactly are you doing in the app?
Piglet | tone tags would be nice
typing the program 😭
dan1st
dan1st7mo ago
yes but how you run it? What is the name of the file?
Piglet | tone tags would be nice
theres a play button t
dan1st
dan1st7mo ago
just t?
Piglet | tone tags would be nice
this is better I hope?
dan1st
dan1st7mo ago
yes oh so it's t.java? Typically the class name should match the file name try either naming the file Potential.java or name the class t
Piglet | tone tags would be nice
okay THAT WORKED man 😭😭😭😭😭😭 thanks
JavaBot
JavaBot7mo ago
If you are finished with your post, please close it. If you are not, please ignore this message. Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
dan1st
dan1st7mo ago
good to see Please in the future, don't write code on your mobile for your own sanity I know there are some apps that help with it - I wrote one by myself - but it's still painful
Piglet | tone tags would be nice
lol yeah no its a last resort looks like theres some issue w the program itself now but ill see what I can do
Piglet | tone tags would be nice
wait wait dang it the arranging acc to potential bullshit didnt happen right ugh
dan1st
dan1st7mo ago
I'm not sure what you mean by that
ayylmao123xdd
ayylmao123xdd7mo ago
interesting choice of the testing sentence:GnuTrolling:
JavaBot
JavaBot7mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Piglet | tone tags would be nice
I needed smth in caps that ended with ! or ? so seemed like a good choice 🤷‍♀️ anyway I reopened this for a question why cant I use an integer that stores 0 or 1
Piglet | tone tags would be nice
it says int cannot be converted to boolean but I dont need it to be? is there a rule against this or smth cuz afik you can store any integer in an int variable
dan1st
dan1st7mo ago
a boolean is either true or false not 0 or 1
Piglet | tone tags would be nice
oh yeah that too so why does it show me that error
dan1st
dan1st7mo ago
what exactly error? You cannot assign a number to a boolean
Piglet | tone tags would be nice
its not a boolean tho
Piglet | tone tags would be nice
its an integer
ayylmao123xdd
ayylmao123xdd7mo ago
can u show the line at which the error happens cant see the code on mobile :SkullPixel:
dan1st
dan1st7mo ago
import java.util.;
class Evil
{
public static void main(String args[])
{
int N, div, rem, count=0;
String bin="";
Scanner in=new Scanner(System.in);
System.out.println("Enter number");
N=in.nextInt();
while (N<2 || N<100)
{
System.out.println("ERROR: NUMBER IS <2 OR >100");
System.out.println("Enter number");
N=in.nextInt();
}
div=N;
while(div!=0)
{
rem=div%2;
div=div/2;
bin=bin+(char)rem;
if(rem=1)
count=count+1;
}
System.out.println("BINARY EQUIVALENT: " + bin);
System.out.println("NUMBER OF 1's: " + count);
if(count%2==0)
System.out.println("IT IS AN EVIL NUMBER");
else
System.out.println("IT IS NOT AN EVIL NUMBER");
}
}
import java.util.;
class Evil
{
public static void main(String args[])
{
int N, div, rem, count=0;
String bin="";
Scanner in=new Scanner(System.in);
System.out.println("Enter number");
N=in.nextInt();
while (N<2 || N<100)
{
System.out.println("ERROR: NUMBER IS <2 OR >100");
System.out.println("Enter number");
N=in.nextInt();
}
div=N;
while(div!=0)
{
rem=div%2;
div=div/2;
bin=bin+(char)rem;
if(rem=1)
count=count+1;
}
System.out.println("BINARY EQUIVALENT: " + bin);
System.out.println("NUMBER OF 1's: " + count);
if(count%2==0)
System.out.println("IT IS AN EVIL NUMBER");
else
System.out.println("IT IS NOT AN EVIL NUMBER");
}
}
I'm also on mobile though lol
Piglet | tone tags would be nice
dang beat me to it but thank you huh you get it embedded?
dan1st
dan1st7mo ago
code block 3 backtocks before and after
JavaBot
JavaBot7mo ago
Help Guidelines
1. Don't ask questions like "Can I ask ...?" or "Can someone help me?". It's easier for everyone involved if you provide a detailed description of your problem up-front; this makes it more likely for helpers to want to help, and more likely that you'll get an answer quickly. Please provide code snippets and error messages (if any) to help us help you! 2. Please create a post in <#1023632039829831811> for your questions. Do not use other people's posts for your questions. 3. You may use the /help ping command if your question is urgent. Abusing this will result in warnings and/or a ban. 4. Do not ask for help with exams or homework. You may ask for help with understanding individual concepts and parts of a question, but homework and exam questions that show little effort on your part will most likely go unanswered and may be removed. 5. Do not ask your question if you didn't at least try to solve the problem yourself, are ignorant, or, instead of trying to improve, ask repeating, simple, questions. 6. Format your code using Discord's triple-backtick syntax. 7. For reasons similar to those of Stack Overflow, we currently do not allow content created by ChatGPT while helping other people. You may still share its content, when you are not helping somebody and are not looking to deceive others, for example when discussing ChatGPT and its technology.
From An unknown user
dan1st
dan1st7mo ago
see the GIF
Piglet | tone tags would be nice
oh nono I know how to do that didnt do it cuz w the last program the msg was too long
dan1st
dan1st7mo ago
it wasn't too long lol
Piglet | tone tags would be nice
I meant youre on mobile but you can see the embed?
dan1st
dan1st7mo ago
no I just downloaded it, renamed it to .txt and copied it
Piglet | tone tags would be nice
yeah this ones a lot lot lot more straightforward logically I think so the codes simpler too ah
dan1st
dan1st7mo ago
if(rem=1) rem=1 sets rem to 1 you probably want if(rem==1)
Piglet | tone tags would be nice
OHHHHHHH yeah that was it thanks 😭😭😭
JavaBot
JavaBot7mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Piglet | tone tags would be nice
import java.util.*;
public class p4
{
private boolean isVowel(int c) //checks if character is a vowel
{
return switch(Character.toUpperCase(c))
{
case 'A','E','I','O','U' -> true;
default -> false;
};
}
public static void main(String args[])
{
int a, b, count=0, i, bs;
String sen, sen_2;
char ch;
boolean f, l, t=false;
Scanner in = new Scanner(System.in);
System.out.println("Enter a sentence terminated by '.', '?' or '!'");
sen=in.nextLine(); // stores user input
a=sen.length();
while(t==false) // loops if input sentence does not end with '.', '?' or '!' and takes new input
{
if(sen.charAt(a-1)=='.' || sen.charAt(a-1)=='?' || sen.charAt(a-1)=='!')
t=true;
else
{
System.out.println("Enter a sentence terminated by '.', '?' or '!'");
sen=in.nextLine();
}
}
sen=sen.toUpperCase()+" "; // converts sentence to upper case
a=sen.length();
sen_2=sen;
for(i=0;i<a;i++)
{
ch=sen.charAt(i); // stores each character of the sentence
if(ch==' ')
{
count=count+1; // counts character as per spaces seperating the words
}
}
String word[]=new String[count]; // stores each word of the sentence
String vowel[]=new String[count]; // stores each word of the new sentence
for(i=0;i<count;i++)
{
bs=sen.indexOf(' ');
word[i]=sen.substring(0,bs);
sen=sen.substring(bs, a);
a=sen.length();
}
p4 ob=new p4();
for(i=0;i<count;i++)
{
b=word[i].length();
f=ob.isVowel(word[i].charAt(0));
l=ob.isVowel(word[i].charAt(b-1));
if(f==true && l==true)
{
vowel[i]=word[i];
word[i]=" ";
}
else
vowel[i]=" ";
}
System.out.println();
System.out.println("New Sentence:");
for(i=0;i<count;i++)
if(vowel[i]!=" ")
System.out.print(vowel[i] + " ");
for(i=0;i<count;i++)
if(word[i]!=" ")
System.out.print(word[i]+" ");
}
}
import java.util.*;
public class p4
{
private boolean isVowel(int c) //checks if character is a vowel
{
return switch(Character.toUpperCase(c))
{
case 'A','E','I','O','U' -> true;
default -> false;
};
}
public static void main(String args[])
{
int a, b, count=0, i, bs;
String sen, sen_2;
char ch;
boolean f, l, t=false;
Scanner in = new Scanner(System.in);
System.out.println("Enter a sentence terminated by '.', '?' or '!'");
sen=in.nextLine(); // stores user input
a=sen.length();
while(t==false) // loops if input sentence does not end with '.', '?' or '!' and takes new input
{
if(sen.charAt(a-1)=='.' || sen.charAt(a-1)=='?' || sen.charAt(a-1)=='!')
t=true;
else
{
System.out.println("Enter a sentence terminated by '.', '?' or '!'");
sen=in.nextLine();
}
}
sen=sen.toUpperCase()+" "; // converts sentence to upper case
a=sen.length();
sen_2=sen;
for(i=0;i<a;i++)
{
ch=sen.charAt(i); // stores each character of the sentence
if(ch==' ')
{
count=count+1; // counts character as per spaces seperating the words
}
}
String word[]=new String[count]; // stores each word of the sentence
String vowel[]=new String[count]; // stores each word of the new sentence
for(i=0;i<count;i++)
{
bs=sen.indexOf(' ');
word[i]=sen.substring(0,bs);
sen=sen.substring(bs, a);
a=sen.length();
}
p4 ob=new p4();
for(i=0;i<count;i++)
{
b=word[i].length();
f=ob.isVowel(word[i].charAt(0));
l=ob.isVowel(word[i].charAt(b-1));
if(f==true && l==true)
{
vowel[i]=word[i];
word[i]=" ";
}
else
vowel[i]=" ";
}
System.out.println();
System.out.println("New Sentence:");
for(i=0;i<count;i++)
if(vowel[i]!=" ")
System.out.print(vowel[i] + " ");
for(i=0;i<count;i++)
if(word[i]!=" ")
System.out.print(word[i]+" ");
}
}
Piglet | tone tags would be nice
(same error with 0)
Piglet | tone tags would be nice
why wont it let me
No description
Piglet | tone tags would be nice
💔 I figured it out :cleanteeth:
Piglet | tone tags would be nice
hugs this bruh
No description
Gameboy V
Gameboy V6mo ago
xd where do you get that error? what line
JavaBot
JavaBot6mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Piglet | tone tags would be nice
b=word[i].length() fixed that but im back to this now ughgh I hate this...
ayylmao123xdd
ayylmao123xdd6mo ago
ur trying to add a table with a char
JavaBot
JavaBot6mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
ayylmao123xdd
ayylmao123xdd6mo ago
first type table of string second type is a character you cant add these two together unless u fixed that already idk
Piglet | tone tags would be nice
ohhhhh okay
JavaBot
JavaBot6mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?