In: Computer Science
1.Write complete programs. These programs should be able to compile and run. No psuedocode is allowed. No comments are needed. These programs will be graded for syntax, semantics, and programming style.
Write a complete program to display the following output:
Plan to be
spontaneous tomorrow.
2.
Write complete programs. These programs should be able to compile and run. No psuedocode is allowed. No comments are needed. These programs will be graded for syntax, semantics, and programming style.
Write a complete program to display the results for the area of a triangle. Formula (1/2) x base x height.
public class Main
{
public static void main(String[] args) {
//declaring a string
String str1="Plan to be";
String str2="spontaneous tomorrow.";
//display ouptut
System.out.println(str1);
System.out.println(str2);
}
}
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
double b,h,area;
System.out.println("enter base and height values:");
b=s.nextDouble();
h=s.nextDouble();
area=0.5*b*h;
System.out.println("area of a triangle is : "+area);
}
}