0
The program is supposed to ask for a number between 1 and 12. (I haven’t gotten to the part of certifying that it’s between 1 and 12 but this is the easiest.However I’m supposed to write the code through functions (not that I see much sense being for functions in such an exercise). But by my reasoning does not work. I leave it there. Besides someone knows some page or can explain to me how the types of function works? of the kind I only know public Static void and the public Static final and public Static String(if there really is).
public static void main(String[] args)
{
System.out.println("Idique um número entre 1 e 12");
int num = scanner.nextInt();
System . out . println(num + "Correponde a :" + mesesdoano);
}
public static String mesesdoano()
{
String meses = ("janeiro fevereiromarço abril maio junho julho agosto setembro outubro novembro dezembro "); //vai relacionar o número introduzido com a formula //
Substring=(int (numero*9)-9,int numero*9);// vai buscar á string meses a palavra correspondente de acordo com o número.Cada mês ocupa sempre nove espaços para através dessa "formula" ir buscar a palavra.
return substring;
Your doubt is about what it is
public static void main(String[] args)
or what the code problem (which alias, has many)?– user28595
This line
Substring=(int (numero*9)-9,int numero*9);
is not valid. I was trying to do what specifically ?– Isac
@Article is about the classes of the functions and also about the code.
– Phil
I’m sorry @Isac vo add some comments to the code
– Phil
Your doubt is unclear, please be more specific.
– user28595
@The first is that the code does not accomplish what is intended. The second is that I don’t know what to put after public Static ____ according to what I want to do in this function and if there is any "list" that helps.
– Phil
I believe the mistake
.class expected
, be why you are assigning aint
It’s a class, on the lineSubstring=(int (numero*9)-9,int numero*9);
– Costamilam
@Guilhermecostamilam then what should I assign? is because without the int also does not give
– Phil
I can make an answer with a method that does what you want, but in a different way
– Costamilam
If you think you’re going to help me I really appreciate it. It’s because I’m very new to this and I’m still learning the basics.
– Phil
How you are compiling and running, @Phil ?
– Jefferson Quesado