473,473 Members | 1,888 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to validate records like only 10 record allowed...

1 New Member
Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2.  
  3. class Studentinfo
  4. {
  5.     private int rlno,m1,m2,m3;
  6.     private String sname;
  7.  
  8.     public void getdata(int rlno1,String sname1,int m11,int m22,int m33)
  9.     {
  10.  
  11.         rlno=rlno1;
  12.         sname=sname1;
  13.         m1=m11;
  14.         m2=m22;
  15.         m3=m33;
  16.     }
  17.  
  18.  
  19.  
  20.     void putdata(Studentinfo []students,int s_rlno,int cnt)
  21.     {
  22.         int f=0;
  23.         int i=0;
  24.         int total=0;
  25.         float per=0;
  26.         for(i=0;i<cnt;i++)
  27.         {
  28.             if(students[i].rlno==s_rlno)
  29.             {
  30.                 total=total+students[i].m1+students[i].m2+students[i].m3;
  31.                 per=per+total/3;
  32.                 System.out.println("\n Student Roll no :"+students[i].rlno);
  33.                 System.out.println("\n student Name : "+students[i].sname);
  34.                 System.out.println("\n student marks in m1 :"+students[i].m1);
  35.                 System.out.println("\n student marks in m2 :"+students[i].m2);
  36.                 System.out.println("\n student marks in m3 :"+students[i].m3);
  37.                 System.out.println("\n student total marks :"+total);
  38.                 System.out.println("\n student percentage :"+per);
  39.             }
  40.         }
  41.     }
  42.  
  43.     public void putdata(Studentinfo [] students,int cnt)
  44.     {
  45.         int i=0;
  46.         int total=0;
  47.         float per=0;
  48.         for(i=0;i<cnt;i++)
  49.         {
  50.             total=total+(students[i].m1+students[i].m2+students[i].m3/3);
  51.             per=total/3;
  52.             System.out.println("\n The percentage of student :"+per);
  53.         }
  54.     }
  55. }
  56. public class Student
  57. {
  58.     public static void main(String [] args) throws IOException
  59.     {
  60.         int cnt=0;
  61.         int ch,f=0;
  62.  
  63.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));    
  64.         Studentinfo students[] = new Studentinfo[10];
  65.         do
  66.         {
  67.             System.out.println("\n 1.Enter student Information.");
  68.             System.out.println("\n 2.Display Student Information.");
  69.             System.out.println("\n 3.Display all Student percentage.");
  70.             System.out.println("\n 4.Exit ");
  71.  
  72.             System.out.println("\nEnter Your choice : ");
  73.             ch=Integer.parseInt(br.readLine());
  74.  
  75.             switch(ch)
  76.             {
  77.                 case 1:
  78.                     if(cnt==10)
  79.                     {
  80.                         System.out.println("\n Sorry Data storage Limit Reached ");
  81.                         break;
  82.                     }
  83.                     System.out.println(" Enter Student Roll no:");
  84.                     int srlno1=Integer.parseInt(br.readLine());
  85.                     System.out.println(" Enter student name :");
  86.                     String sname1=br.readLine();
  87.                     System.out.println(" Enter student marks 1 :");
  88.                     int m11=Integer.parseInt(br.readLine());
  89.                     System.out.println(" Enter student marks 2 :");
  90.                     int m22=Integer.parseInt(br.readLine());
  91.                     System.out.println(" Enter student marks 3 :");
  92.                     int m33=Integer.parseInt(br.readLine());
  93.  
  94.                     students[cnt] =new Studentinfo();
  95.                     students[cnt++].getdata(srlno1,sname1,m11,m22,m33);
  96.                     f=1;
  97.                     break;
  98.                 case 2:
  99.  
  100.                     System.out.println("\n Enter Roll NO :");
  101.                     int s_rlno=Integer.parseInt(br.readLine());
  102.                     students[0].putdata(students,s_rlno,cnt);
  103.                     break;
  104.                 case 3:
  105.                     students[0].putdata(students,cnt);
  106.                     break;
  107.                 case 4:
  108.                     System.out.println("\n Thank you ");
  109.                     break;
  110.                 default:
  111.                     System.out.println("\n Invalid option ");
  112.             }
  113.             }while(ch!=4);
  114.         }
  115.  
  116. };
  117.  
when there are no records then i want to display one message like no record found...
when i select choice-2 and if there is no record then it must display msg..
May 3 '11 #1
0 1017

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

Similar topics

3
by: Fred | last post by:
I have a query that returns multiple identical records, however it should only return one. Indeed there is only one record for the OrderActionTypecode of 'P' yet there are two orderactions so it...
0
by: DS | last post by:
Hi Guys (and ladies): I have a parameter query in A2K that asks for records based on certain criteria. It returns the name and address fields of each record. I usually get about 5 to 10 records...
3
by: Mike Turco | last post by:
I'm working on an application that imports and exports tons of CSV data, like 64,000 records per file, and six or seven files in a set. First off, by the tine I import a few hundred thousand...
9
by: Sharktyyfa | last post by:
Hi, hoping someone can help. Access 2003, WinXP. I have built a database that uses synchro to co-ordinate with the mothership. All is well. The person i built it for wants the satellites...
16
by: LP | last post by:
Hi, Every morning a .NET application downloads a file with cumulative data which needs to be appended to SQL Server table. This program needs to identify records that have not been previously...
1
by: Jim McGivney | last post by:
I get the following error. Asp.net does not like my web.config file - line 108. Any suggestions would be appreciated. Configuration Error Description: An error occurred during the processing...
3
by: WiseG1rly | last post by:
Hey everyone! I am completley new and I will start off by saying that I am not a programmer - figuring out this search took so long! I am debugging now and would appreciate any help :) ...
4
by: robtyketto | last post by:
Greetings, I added my error checking (see code below) on the Form "On Current" event as I believe this code will run upon any action on screen being actioned. Errors happen when users are...
1
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi, I'm having an issue in my C#.NET desktop application where two or more people viewing/editing the same record (from SQL Server) keep overwriting each others changes. Is there a setting in...
2
by: hschleckser | last post by:
I want to print a report. Each record may have blank fields which I eliminate with the can shrink property. However this leaves varying spaces between records. I would like to control the space...
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,...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.