Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Report { //instance variables int roll; //store roll number String name; //store name double sub1; //store marks of subject 1 double sub2; //store

public class Report { //instance variables int roll; //store roll number String name; //store name double sub1; //store marks of subject 1 double sub2; //store marks of subject 2 double sub3; //store marks of subject 3 double sub4; //store marks of subject 4 double total; //store total marks double percent; //store percentage char grade; //store grade public Report(int roll, String name, double sub1, double sub2, double sub3, double sub4) { //parameterized constructor //setting the values this.roll = roll; this.name = name; this.sub1 = sub1; this.sub2 = sub2; this.sub3 = sub3; this.sub4 = sub4; total=0; percent=0; grade=' '; } public int getRoll() { //getter for roll number return roll; } public void setRoll(int roll) { //setter for roll number this.roll = roll; } public String getName() { //getter for name return name; } public void setName(String name) { //setter for name this.name = name; } public double getSub1() { //getter for subject 1 return sub1; } public void setSub1(double sub1) { //setter for subject 1 this.sub1 = sub1; } public double getSub2() { //getter for subject 2 return sub2; } public void setSub2(double sub2) { //setter for subject 2 this.sub2 = sub2; } public double getSub3() { //getter for subject 3 return sub3; } public void setSub3(double sub3) { //setter for subject 3 this.sub3 = sub3; } public double getSub4() { //setter for subject 4 return sub4; } public void setSub4(double sub4) { //setter for subject 4 this.sub4 = sub4; } public char getGrade() { //getter for grade return grade; } public void setGrade(char grade) { //setter for grade this.grade = grade; } public double calcTotal() { //function returns total marks this.total=sub1+sub2+sub3+sub4; //calculate return total; } public double calcPercent() { //function returns total percentage this.percent=(total/400)*100; //calculate percentage return percent; //return } @Override public String toString() { //print details return "" + roll + "\t" + name + "\t" + sub1 + "\t\t" + sub2 + "\t\t" + sub3 + "\t\t" + sub4 + "\t\t" + total + "\t" + percent + "%\t\t"+grade+""; } } ReportCard.java import java.util.*; public class ReportCard { public static void main(String[] args) { Scanner sc=new Scanner(System.in); //scanner //creating arraylist of Report ArrayList report=new ArrayList(); char ch=' '; int id=0; double sub1,sub2,sub3,sub4,total,percent; String name=""; while(true) { //infinite while loop System.out.print("Enter Student name: "); name=sc.nextLine(); //take name from user System.out.print("Enter Student roll: "); id=sc.nextInt(); //take roll number System.out.print("Enter marks of 4 subject: "); //take the 4 marks sub1=sc.nextDouble(); //mark of subject 1 sub2=sc.nextDouble(); //mark of subject 2 sub3=sc.nextDouble(); //mark of subject 3 sub4=sc.nextDouble(); //mark of subject 4 sc.nextLine(); report.add(new Report(id,name,sub1,sub2,sub3,sub4)); //add it in the list System.out.print("Do you want to continue(y/n): "); ch=sc.next().charAt(0); //ask the choice from user sc.nextLine(); if(ch=='n') //if chosen n then terminate the loop break; } System.out.println("Roll\tName\tSubject 1\tSubject 2\tSubject 3\tSubject 4\tTotal\tPercentage\tGrade"); System.out.println("------------------------------------------------------------------------------------------------------------------"); //print details for(Report r:report) { //use for each loop total=r.calcTotal(); //call the total method percent=r.calcPercent(); //call the percentage calculation method if(percent>90) { //if percentage greater than 90 r.setGrade('A'); } else if(percent>80) { //if percentage greater than 80 r.setGrade('B'); } else if(percent>70) { //if percentage greater than 70 r.setGrade('C'); } else if(percent>60) { //if percentage greater than 60 r.setGrade('C'); } else if(percent>50) { //if percentage greater than 50 r.setGrade('D'); } else if(percent>40) { //if percentage greater than 40 r.setGrade('E'); } else { r.setGrade('F'); } System.out.println(r); //print the details } } }

Explanation

Please refer to solution in this step.

AM code

%>>>>>>>>>>>>>>>>>>>> Tuterial on AM Modulation <<<<<<<<<<<<<<<<<<<<<<<<<< clc; close all; clear all;

%XXXXXXXXXXXXXXXXXXXXXXXXXXX Define AM modulation Index XXXXXXXXXXXXXXXXXXX disp(' example: m=1 means 100% modulation'); %m=input(' Enter the value of modulation index (m) = '); m=1 ; % for 100% modulation if ( 0>m || m>1 ) error('m may be less than or equal to one and geter than to zero'); end % hello Comm Sys class % XXXXXXXXXXXXXXXXX modulating signal generation m(t) XXXXXXXXXXXXXXXXXXXXXXXXXX Am=5; % Amplitude of modulating signal fa=2000; % Frequency of modulating signal Ta=1/fa; % Time period of modulating signal t= 0: Ta/999 : 6*Ta; % Total time for simulation ym=Am*cos(2*pi*fa*t); % m(t) Eqation of modulating signal figure(1) subplot(3,1,1); plot(t,ym), grid on;% Graphical representation of Modulating signal title ( ' Modulating Signal '); xlabel ( ' time(sec) '); ylabel (' Amplitud(volt) ');

%XXXXXXXXXXXXXXXXXXXXX carrier signal generation c(t) XXXXXXXXXXXXXXXXXXXXXXXXXX Ac=Am/m;% Amplitude of carrier signal [ where, modulation Index (m)=Am/Ac ] fc=fa*10;% Frequency of carrier signal Tc=1/fc;% Time period of carrier signal yc=Ac*cos(2*pi*fc*t);% Eqation of carrier signal subplot(3,1,2); plot(t,yc), grid on;% Graphical representation of carrier signal title ( ' Carrier Signal '); xlabel ( ' time(sec) '); ylabel (' Amplitud(volt) ');

%XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX AM Modulation S(t) XXXXXXXXXXXXXXXXXXXXXXXXXXX y=Ac * ( 1 + m*cos(2*pi*fa*t) ) .* cos(2*pi*fc*t); % Equation of Amplitude %modulated signal subplot(3,1,3); plot(t,y);% Graphical representation of AM signal title ( ' Amplitude Modulated signal '); xlabel ( ' time(sec) '); ylabel (' Amplitud(volt) '); grid on; %>>>>>>>>>>>>>>>>>>>>>> end of program <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions

Question

How does selection differ from recruitment ?

Answered: 1 week ago

Question

3-4. What are the three attributes of quality information? [LO3]

Answered: 1 week ago