Question: Create a class named Yourlastname _ Yourfirstname _ midterm ( 5 pts ) . In this class, 1 . Write a static method named problem
Create a class named YourlastnameYourfirstnamemidterm pts In this class, Write a static method named problem that accepts a positive integer as the argument and returns the sum of all the positive even numbers that are less than or equal to the input number. You mustuse a while loop to solve the problem. ptsTest case: problem returns because Write a static method named problem that receives a positive integer n as the argument andcalculates the sum below by using a loop. Return the result.total x x n x n ptsTest case: problem returns because xxx x x Write a static method named problem that accepts a string. Replace every occurrence of the first character with $ except for the first character itself. Capitalize the first letter of this word. Returnthe results. ptsTest case: problemabcabcabcabc returns "Abc$bc$bc$bc Write an inner public class named Triangle not static In this class, Write three private instance variables, a b and c Each instance variable represents the lengthof a line type double pts Write a constructor method to initialize each instance variable. pts Write a public getset method for each instance variable. pts Write a public method named istriangle to calculate whether you can form a valid triangle with these three lines. Return true if a valid triangle can be formed, return false otherwise. Hint:the length of a side must be less than the combined length of the other two sides. pts Write a public method named gettriangletype In this method, check whether you can form a valid triangle with these three lines by using the method, istriangle If no return "cannotform a triangle". If yes, determine whether the triangle is equilateral, isosceles, or scalene. Return the result. Hint: An equilateral triangle has equal sides. An isosceles triangle has equal sides. A scalene triangle has different sides. ptsTest case: Create two objects of the Triangle class, triangle with lines of length and andtriangle with lines of length For each object, call istriangle and gettriangletype respectively Write the main method to run each method with the provided test case. pts
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
