473,396 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Arrays case

1
please help me....
1.Why doesn't this run?
2.When the user makes the first input and asks if the data needs
to be inserted again, why doesn't it run again?
3.How to make array size dynamic data types?[/b]
Attached Files
File Type: txt ko.txt (738 Bytes, 99 views)
May 19 '20 #1
2 3064
dev7060
636 Expert 512MB
The while loop has no body because of the semicolon.
May 19 '20 #2
Ishan Shah
47 32bit
Using the following code your program will work as per your requirements :

Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2. class Example
  3. {
  4.     public static void main(String args[])
  5.     {
  6.         Scanner input=new Scanner(System.in);
  7.                          int[] x=new int[4];
  8.                          String[] y=new String[5];
  9.                          char r;
  10.         System.out.print("How Many Student Detail Do you want Enter  :");
  11.                          int count=Integer.parseInt(input.nextLine());
  12.         for(int i=1;i<=count;i++)
  13.         {
  14.                              System.out.print("Enter student ID :");
  15.                              x[i]=Integer.parseInt(input.nextLine());
  16.                              System.out.print("Enter student Name :");
  17.                                               y[i]=input.nextLine();
  18.  
  19.          }    
  20.  
  21.                          do 
  22.         {
  23.             System.out.print("Student has been added successfully.Do you want to add a new student (y/n) :");
  24.                              r = input.next().charAt(0);
  25.             count=1;  
  26.             System.out.print("Enter student ID :");
  27.                              x[count]=Integer.parseInt(input.nextLine());
  28.                              System.out.print("Enter student Name :");
  29.                                               y[count]=input.nextLine();
  30.  
  31.                          } while (r == 'y');
  32.  
  33.     }
  34. }
  35.  
  36.  
May 22 '20 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: muser | last post by:
for the following code: strncpy(temp_issue, &temp1, 4); files.rec1.issue_rec = atol(temp_issue); cout<<files.rec1.issue_rec<<endl; on execution I get the following. 0x0fd10 a memory...
19
by: Canonical Latin | last post by:
"Leor Zolman" <leor@bdsoft.com> wrote > "Canonical Latin" <javaplus@hotmail.com> wrote: > > > ... > >But I'm still curious as to the rational of having type >...
3
by: T | last post by:
Hi all. I have a problem I have not been able to find a reference about. I am using VB6 and am only a hobbyist programmer. I have 7 arrays of type MyData. Type MyData has 23 elements. Which...
79
by: Me | last post by:
Just a question/observation out of frustration. I read in depth the book by Peter Van Der Linden entitled "Expert C Programming" (Deep C Secrets). In particular the chapters entitled: 4: The...
8
by: masood.iqbal | last post by:
All this time I was under the illusion that I understand the concept of multi-dimensional arrays well ---- however the following code snippet belies my understanding. I had assumed all along...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
18
by: Mike Bartels | last post by:
Hi Everyone! I have two Arrays A and B. Both arrays are byte arrays with 7 bytes each. The contents of array A and B are the same A = {1, 2, 3, 4, 5, 6, 7}; B = {1, 2, 3, 4, 5, 6, 7}; When...
110
by: alf | last post by:
Hi, is it possible that due to OS crash or mysql itself crash or some e.g. SCSI failure to lose all the data stored in the table (let's say million of 1KB rows). In other words what is the worst...
1
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are...
29
weaknessforcats
by: weaknessforcats | last post by:
Arrays Revealed Introduction Arrays are the built-in containers of C and C++. This article assumes the reader has some experiece with arrays and array syntax but is not clear on a )exactly how...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.