From 166077a7762b52ece148b49e921462c4b3227502 Mon Sep 17 00:00:00 2001 From: sunidhi-ux <72993008+sunidhi-ux@users.noreply.github.com> Date: Sun, 1 Nov 2020 06:46:45 +0530 Subject: [PATCH 1/2] Create Student.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Creating a class as Student. Write a program in Java to display the names and roll numbers of students. Create an array of 10 students and initialize the array with user input. Handle ArrayIndexOutOfBoundsExeption, so that any such problem doesn’t cause illegal termination of the program. Read a character from the user and display the student names starting with the given character. --- Student.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Student.md diff --git a/Student.md b/Student.md new file mode 100644 index 0000000..e98abda --- /dev/null +++ b/Student.md @@ -0,0 +1,58 @@ +import java.util.*; +class StudentA +{ + protected String name; + protected int roll_no; + void read() + { + Scanner reader=new Scanner(System.in); + System.out.println("Enter Student name"); + name=reader.next(); + System.out.println("Enter Student Roll number"); + roll_no=reader.nextInt(); + } + String display() + { + return name; + + } +} + +public class Experiment4StudentArray { + + public static void main(String[] args) throws ArrayIndexOutOfBoundsException + { + Scanner reader=new Scanner(System.in); + try + { + System.out.println("Enter number of Students"); + int n=reader.nextInt(); + StudentA s[]=new StudentA[10]; + int i; + for(i=0;i Date: Sun, 1 Nov 2020 06:55:31 +0530 Subject: [PATCH 2/2] Create FizzBuzz.md Prints "FizzBuzz " if the number is divisible by 15 ,"Fizz" if it's divisible by 3 and "Buzz" if it's divisible by 5. --- FizzBuzz.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 FizzBuzz.md diff --git a/FizzBuzz.md b/FizzBuzz.md new file mode 100644 index 0000000..d881d86 --- /dev/null +++ b/FizzBuzz.md @@ -0,0 +1,31 @@ +// CPP program to print Fizz Buzz +#include + +int main(void) +{ + int i; + for (i=1; i<=100; i++) + { + // number divisible by 3 and 5 will + // always be divisible by 15, print + // 'FizzBuzz' in place of the number + if (i%15 == 0) + printf ("FizzBuzz\t"); + + // number divisible by 3? print 'Fizz' + // in place of the number + else if ((i%3) == 0) + printf("Fizz\t"); + + // number divisible by 5, print 'Buzz' + // in place of the number + else if ((i%5) == 0) + printf("Buzz\t"); + + else // print the number + printf("%d\t", i); + + } + + return 0; +}