Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1.Write a constructor for the Course class that takes a String to represent the course subject and an int to represent the course number. It
1.Write a constructor for the Course class that takes a String to represent the course subject and an int to represent the course number. It should ensure that the subject is at most 4 characters long and is all capitalized, and that the number is between 400 and 799 (defaulting to 401 if an invalid number was enetered.)
You may find the method Character.toUpperCase helpful in this task.
Grading 6 Save Run Tests Full Screen new Coursel "CS", 300 ) 0 / 0 pts - Click for details FAILED Course.java New 1 - public class Course{ 2 3 private String subject; 4 private int number; 5 6 // YOUR CODE HERE 7 8- public String toString(){ 9 return subject + " " + number; 10 } 11 12 } new Coursel "CS", 416 ) 0 / 0 pts - Click for details FAILED new Coursel "CS", 999 ) 0 / 0 pts - Click for details FAILED new Coursel "math", 425 ) 0 / 0 pts - Click for details FAILED new Coursel "MATH", 425 ) 0 / 0 pts - Click for details FAILED new Coursel "MATHEMATICS", 425 ) 0 / 0 pts - Click for details FAILED
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started