Hi, I need help on this lab assignment in my Computer Sicence class. I don\'t un
ID: 3743391 • Letter: H
Question
Hi, I need help on this lab assignment in my Computer Sicence class. I don't understand how I'm supposed to depict the same coding format for the stick figure. Please help me. I'm a beginner in Computer Science. Below is the Lab.
Lab:
1. Go to www.ascii-art.de/ascii/s/stickman.txt, select one stick figure from the list, write a Java program to display your favorite figure.
2. User Scanner to get 3 integers from user input, calculate and display the sum, product and average (with 2 decimal digits) of these 3 numbers. (Test data: 1,2,8, output: sum=11, product=16, average=3.67.)
Explanation / Answer
Answers :
1. Printing
Man stabs a poor defencless man
public class Stick {
public static void main(String[] args) {
printManStabbed();
}
private static void printManStabbed() {
// TODO Auto-generated method stub
System.out.println(" " + 0 + " " + "\0");
System.out.println("/0--- :\");
System.out.println("/ > / >");
}
}
2.
import java.util.Scanner;
public class Arithmetic {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
Integer a = s.nextInt();
Integer b = s.nextInt();
Integer c = s.nextInt();
Integer sum = a+b+c;
Integer product = a*b*c;
Double average = sum/(Double)3.0;
System.out.println("The sum is : " + sum);
System.out.println("The product is : " + product);
System.out.printf("The average is : %.2f" , average);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.