For each problem, write pseudocode as shown in all examples on Blackboard for al
ID: 3779154 • Letter: F
Question
For each problem, write pseudocode as shown in all examples on Blackboard for all Chapters that we have covered, without any housekeeping or detail or detailLoop or any other modules. All requirements that have been given for homework programs apply here too. Follow the Good Program Design Example from the Chapter 2 Reading folder on Blackboard, and what has been demonstrated in all examples on Blackboard. Declare constants for all quantities that are known at the time of writing the program, variables for the unknowns.
Our college's Workforce Solutions department offers non-credit classes in various areas of interest in the community, as shown below, along with their fees. Using arrays where applicable, design one program that Continuously accepts a class number and then displays the class's name, until the user enters an appropriate sentinel value to stop entering input. Each time the user enters a valid class number, the program asks the user if he/she wants to sign up for the class, and if they do, simply updates the count of people who have signed up for the class. Once the user decides to stop, the program displays each class number and name a count of the number of people signed up for each class the total number of people signed up for classes the average class enrollment the names of the highest enrolling class and the lowest enrolling class - this should be done without any sorting The table above shows only the current group of classes that have been scheduled. The program must be capable of being modified to accommodate more or fewer classes later by editing only one line of code.Explanation / Answer
package com.bp.common;
public class Class1 {
public int classNo;
public String className;
public int classFees;
public int count;
public Class1(int classNo, String className, int classFees) {
this.classNo = classNo;
this.className = className;
this.classFees = classFees;
}
public int getClassNo() {
return classNo;
}
public void setClassNo(int classNo) {
this.classNo = classNo;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public int getClassFees() {
return classFees;
}
public void setClassFees(int classFees) {
this.classFees = classFees;
}
@Override
public String toString() {
return "Class [classNo=" + classNo + ", className=" + className + ", classFees=" + classFees + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + classFees;
result = prime * result + ((className == null) ? 0 : className.hashCode());
result = prime * result + classNo;
result = prime * result + count;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Class1 other = (Class1) obj;
if (classFees != other.classFees)
return false;
if (className == null) {
if (other.className != null)
return false;
} else if (!className.equals(other.className))
return false;
if (classNo != other.classNo)
return false;
if (count != other.count)
return false;
return true;
}
}
-----------------------------------------------------------------------------------
package com.bp.common;
import java.util.Scanner;
public class Classes {
public static int noofClasses;
static Class1[] classes = new Class1[100];
static int count = 0;
static int count1 = 0;
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
try{
System.out.println("1 insertclass");
System.out.println("2. quit");
System.out.println("enter your choice");
int choice = scanner.nextInt();
switch (choice) {
case 1:
System.out.println("enter the class number");
int count2 = 0;
int classno = 0;
String classname = null;
int classfees = 0;
classno = scanner.nextInt();
if (classno < 0) {
System.out.println(" please enter valid class no");
main(args);
} // end if
else {
System.out.println("enter class name");
classname = scanner.next();
System.out.println("enter the class fee");
classfees = scanner.nextInt();
Class1 cl = new Class1(classno, classname, classfees);
classes[count] = cl;
++count;
// System.out.println(count);
for (int i = 0; i < classes.length; i++) {
if (classes[i].equals(cl)) {
classes[i].setCount(++count1);
main(args);
} // endif
} // end for
classes[count].setCount(++count2);
main(args);
}
break;
case 2:
System.out.println("do you want stop giving the input?");
String word = scanner.next();
System.out.println("do you want stop exit press y/n");
if (word.trim().equals("y"))
break;
else
main(args);
default:
System.out.println("bad choice");
main(args);
break;
}
System.out.println("the count is" + count);
}catch(Exception e)
{
System.out.println("the operations are aborted");
}
}
}
output
1 insertclass
2. quit
enter your choice
1
enter the class number
25
enter class name
ghjk
enter the class fee
355
1 insertclass
2. quit
enter your choice
2
do you want stop giving the input?
y
do you want stop exit press y/n
the count is1
the operations are aborted
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.