Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Object-Oriented Programming in Java: Student and Bill Class Implementation, Assignments of Java Programming

Java lab exercises that include the codes for java classes ,construtor,operator overloading and basics

Typology: Assignments

2020/2021

Uploaded on 02/22/2022

arun-kumawat-20bce1226
arun-kumawat-20bce1226 ๐Ÿ‡ฎ๐Ÿ‡ณ

5 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1. Create Student class with properties , Register number ,list of course
code as array, List of marks in all courses as array.
โ—‹ Register number should be automatically generated ( use static with
the initial value as 1000.
โ—‹ Course code should begin with โ€œCSEโ€. If any other value is entered
ignore and ask to enter correct value.
โ—‹ Marks should not be negative and should not be above 100.
Create N object for a student class . Write appropriate instance methods to
perform the following operations
โ—‹ Display the result analysis details like, pass percentage, class average,
No of people got below 50% for all courses with the course code.
โ—‹ For each course display the register number and marks who got
maximum mark. And also display which course got the highest mark
among all courses.
Code:
import java.util.*;
public class student
{
int rno;
static int ln=2;
String[] lc=new String[ln];
int[] lm=new int[ln];
static int rn=1000;
public static void main(String args[])
{
int n;
Scanner sc =new Scanner(System.in);
n=sc.nextInt();
sc.nextLine();
student s1[]=new student[n];
for(int i=0;i<n;++i)
{
s1[i]=new student();
s1[i].rno=rn+i;
for(int j=0;j<ln;++j)
{
System.out.println("For "+s1[i].rno+":");
pf3
pf4
pf5

Partial preview of the text

Download Object-Oriented Programming in Java: Student and Bill Class Implementation and more Assignments Java Programming in PDF only on Docsity!

  1. Create Student class with properties , Register number ,list of course code as array, List of marks in all courses as array. โ—‹ Register number should be automatically generated ( use static with the initial value as 1000. โ—‹ Course code should begin with โ€œCSEโ€. If any other value is entered ignore and ask to enter correct value. โ—‹ Marks should not be negative and should not be above 100. Create N object for a student class. Write appropriate instance methods to perform the following operations โ—‹ Display the result analysis details like, pass percentage, class average, No of people got below 50% for all courses with the course code. โ—‹ For each course display the register number and marks who got maximum mark. And also display which course got the highest mark among all courses. Code: import java.util.*; public class student { int rno; static int ln=2; String[] lc=new String[ln]; int[] lm=new int[ln]; static int rn=1000; public static void main(String args[]) { int n; Scanner sc =new Scanner(System.in); n=sc.nextInt(); sc.nextLine(); student s1[]=new student[n]; for(int i=0;i<n;++i) { s1[i]=new student(); s1[i].rno=rn+i; for(int j=0;j<ln;++j) { System.out.println("For "+s1[i].rno+":");

do { System.out.println("Course:"); s1[i].lc[j]=sc.nextLine(); if((s1[i].lc[j].substring(0,3)).equals("CSE")!=true) System.out.println("Enter again"); }while((s1[i].lc[j].substring(0,3)).equals("CSE")!=true); do { System.out.println("Marks: "); s1[i].lm[j]=sc.nextInt(); if(s1[i].lm[j]<0 && s1[i].lm[j]>100) System.out.println("Enter again"); }while(s1[i].lm[j]<0 && s1[i].lm[j]>100); sc.nextLine(); } } int p1=0,p2=0,sum1=0,sum2=0,be=0; for(int i=0;i<n;++i) { if(s1[i].lm[0]>40) ++p1; sum1+=s1[i].lm[0]; if(s1[i].lm[1]>40) ++p2; sum2+=s1[i].lm[1]; if(s1[i].lm[1]<50 && s1[i].lm[0]<50) ++be; } double ps1=(double)p1/n100.0; double ca1=(double)sum1/(n); double ps2=(double)p2/n100.0; double ca2=(double)sum2/(n); int max1=0,m1=0,m2=0,max2=0; for(int i=0;i<n;++i) { if(s1[i].lm[0]>m1) { max1=s1[i].rno; m1=s1[i].lm[0]; } if(s1[i].lm[1]>m2) {

  1. Define a class for Bill in a super market which comprised of details like Bill No, contact number, item details[], unit price[], price [], Total Bill amount, discount, final bill amount. โ—‹ Bill number should be generated automatically (starts from 52330) โ—‹ Contact number be should be 10 digit number โ—‹ Item details and unit price need to be accepted from the user and price of each item and total price need to be calculated. โ—‹ If the total price exceeds 3000 give discount of 2% of the total bill amount. Create N bill object objects and write appropriate code to perform the following:

โ—‹ Display number of customers who got discounts and their phone numbers โ—‹ Which customer got highest purchase display phone number and amount.( there may be more than one bill for each customer) โ—‹ Calculate the overall discount percentage given for the customers. Code: import java.util. Scanner; class Bill{ static int id=52330; int no; String cnum; String items[]=new String[10]; int uprice[]=new int[10]; int quantity[]=new int[10]; int price[]=new int[10]; int total; Bill(String i[],int up[],int q[],String cn){ no=id++; items=i; uprice=up; cnum=cn; quantity=q; for(int j=0;j<items.length;j++){ price[j]=uprice[j]*quantity[j]; total+=price[j]; } } void discount(Bill b[],int n){ int max=0,index=0; for(int i=0;i<n;i++){ if(b[i].total>3000) System.out.println(b[i].no+" "+b[i].cnum); if(b[i].total>max){ max=b[i].total; index=i;