• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

arrays

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone suggest we about these and these are to be done with just using arrays and neither with objects or packages??
1)In the given two dimensional array, find out the position of number 66 and print.

Input - int[][] a2 = {{5, 8, 9, 4},{11, 55, 66, 88}};

Output - 55 digit found at row - and column -???

2)Create a char array and add name 'VENKATESH PILLAI'.

Find out how many times character 'A' is repeating in the name and Position of character 'A'.


Output -

Character 'A' repeating 2 times

Position of 'A' is

Position of 'A' is

its really urgent please!!! reply soon
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi dan,

Welcome to the Ranch! This looks like a homework question. Here at the Ranch we like to encourage you to DoYourOwnHomework (<- link). We can and still will help you out, but first, you should ShowSomeEffort - the work that you have done and are having trouble completing, and TellTheDetails - let us know exactly the parts you are struggling with.

So if you could please show us what you have done and where you are having trouble, it would help us help you out.
 
nick danasi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:Hi dan,

Welcome to the Ranch! This looks like a homework question. Here at the Ranch we like to encourage you to DoYourOwnHomework (<- link). We can and still will help you out, but first, you should ShowSomeEffort - the work that you have done and are having trouble completing, and TellTheDetails - let us know exactly the parts you are struggling with.

So if you could please show us what you have done and where you are having trouble, it would help us help you out.



Hi steve , thanks for reply and its not homework question.
class d2{
public static void main(String [] args)
{
int i;
int j;
int [][] a = {{5,8,9,4},{11,55,66,88}};
System.out.print(" 55 digit found at row:");
for(i=1;i<a.length;++i)
{
for(j=1;j<a[i].length;j++)
{
System.out.print(a[i]);
}
System.out.print(a[j]);
}
}
}
this code i tried for array position and could suggest about the character i would do it myself.
 
nick danasi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi steve , thanks for reply and its not homework question.

this code i tried for array position and could suggest about the character i would do it myself.
i have the code for repeating char and there are no errors but i am not able to get an output to it
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

thanks for reply and its not homework question.


If it's not your homework then why is it "really urgent"?

Please UseCodeTags (← click) when posting code as it makes it easier for people to read your code. I've added them for you this time.
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Arrays in Java start at index 0 but your code starts at 1.
Can you explain what your code is supposed to do and how that relates to the question.

Actually, on second thoughts, ignore the above and follow the advice below:

I suggest you StopCoding (← click) right now and write out in your native language how you would solve this yourself. Write out every step in detail describes each action you would take then look at converting this to code.
 
nick danasi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the reason i said urgent and soon because i was trying for a long time.
i have another issue

public class Snippet
{
public static void main(String [] args){
String week[][] = {{"First","Monday"},{"Second","Tuesday"},{"Third","Wednesday"},{"Fourth","Thursday"},{"Fifth","Friday"},{"Sixth","Saturday"},{"Seventh","Sunday"}};
for(int i= 0;i< week.length;i++)
{
System.out.print(week[i][0]);
System.out.print( " day of the week " + " is: " );
for(int j= 1;j<week[0].length;j++)
{
System.out.println();
System.out.print(week[0][j]);
}
//System.out.print(week[0][j]);
System.out.println();
}
}
}
output is supposed to be first day of the week is monday till sunday but i am getting all days of the week as monday
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code as I have previously requested. Also please post the code you are running, this code won't compile. - Ninja edit
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you have an inner for loop, there are only two elements in that array and you are ignoring the first element?
 
nick danasi
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

String week[][] = {{"First","Monday"},{"Second","Tuesday"},{"Third","Wednesday"},{"Fourth","Thursday"},{"Fifth","Friday"},{"Sixth","Saturday"},{"Seventh","Sunday"}};
for(int i= 0;i< week.length;i++)
System.out.print(week[i][0]);
System.out.print( " day of the week " + " is: " );
for(int j= 1;j<week[0].length;j++)
System.out.println();
System.out.print(week[0][j]);
System.out.println();

this is code which compiles
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What has happened to the curly braces?
And where are the code tags I keep suggesting you use. If you post unformatted code then it makes it very hard to read and if your code is hard to read then people won't bother and so you won't get any answers to your problem..
 
reply
    Bookmark Topic Watch Topic
  • New Topic