Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use JGrasp to design and implement the following programs (from the end of Chapt

ID: 3861745 • Letter: U

Question

Use JGrasp to design and implement the following programs (from the end of Chapter 6 in the textbook) and understand what they do. Each program includes a main method and the specified method(s) in the problem statement. Notice that the main method is used to test the specified method(s). Required: Use java assert statement to validate program input values when conditions applied to inputs (for int and char types). See Chapter 3 slides for code examples. Apply this requirement to both lab exercises and assignment programs. Design and implement a Java program for programming exercise 6.7, page 235, from the textbook (name it InvestmentValue). Implement the main method as stated in the problems statement. Sample output is given in the textbook. Document your code, and organize the outputs as shown in the sample output using escape characters. Design and implement a Java program for programming exercise 6.15, page 237, from the textbook (name it TaxTable). Design the program to print out separate tables for filing status (Single, Married Joint or Qualifying Widow(er), Married Separate, and Head of house). Document your code, and organize the outputs use escape characters. Design and implement two Java programs for programming exercise 6.19, page 238. The first program (called My Triangle) is to implement the specified methods. The second program (called TestMyTriangle) is to test the first program methods. Program TestMyTriangle is used to compute the area of a triangle if the input is valid. Notice that method isvalid () is used to validate the input before attempting to compute the area. See listings 10 and 11 (page 224) on how to write 2 programs (main program and test program). Design the test program main method such that it allows the user to re-run the program with different inputs ((i.e., use a loop structure). Document your code and organize the outputs properly using escape. Save both programs in the same folder. Design and implement a Java program for programming exercise 6.30, page 241, from the textbook (name it CrapsGame). Rolling a dice is simply generating a random integer number between 1 and 6. Write a separate method for this function, call it rollDie() to return the generated number (one number between 1 and 6). Do NOT print anything inside this method. Follow the game rules stated in the problem statement. Use escape characters to format the outputs as shown in the sample outputs.

Explanation / Answer

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;

class MyTriangle
{
double side1,side2,side3;
public boolean isValid(double side1, double side2, double side3)
{
return (side1 + side2 > side3 && side1 + side3 > side2 && side2 + side3 > side1);
}
}
class TestMyTriangle extends MyTriangle
{
public double area(double side1, double side2, double side3)
{
double s;
double area;
s = (side1 + side2 + side3)/2;
area = Math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
return area;
}
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int chck;
TestMyTriangle test= new TestMyTriangle();
do{
System.out.println("Enter the sides of the triangle: ");
double side1,side2,side3;
side1=sc.nextDouble();
side2=sc.nextDouble();
side3=sc.nextDouble();
if(test.isValid(side1,side2,side3)){
  
System.out.println("The area of the traingle is : " +test.area(side1,side2,side3));}
else{
System.out.println("Inavid Sides Entered ");
}
System.out.println("Do you want to test for another set of sides:(Enter 1 to continue 0 to Quit)? ");
chck=sc.nextInt();
}while(chck!=0);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote