import java.util.Scanner;
public class Lab6d {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
// TODO: get user choice
// TODO: call printTable method passing choice as the
parameter
}
public static void printTable(int stop) {
// TODO: print header
// TODO: loop to print table rows up to stop value
}
import java.util.Scanner;
public class Lab6d {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
System.out.println("enter integer between 1 and 30 : ");
int n=scnr.nextInt();
printTable(n);
}
public static void printTable(int stop) {
System.out.println("Pound\tKilograms");
for(int i=1;i<=n;i++)
{
System.out.println(i+"\t\t"+i*0.45);
}
}
import java.util.Scanner; public class Lab6d { public static void main(String[] args) { Scanner scnr =...
import java.util.Scanner; public class TriangleMaker { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Welcome to the Triangle Maker! Enter the size of the triangle."); Scanner keyboard = new Scanner(System.in); int size = keyboard.nextInt(); for (int i = 1; i <= size; i++) { for (int j = 0; j < i; j++) { System.out.print("*"); } System.out.println(); } for (int...
import java.util.Scanner; public class TempConvert { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); //ask the user for a temperature System.out.println("Enter a temperature:"); double temp = scnr.nextDouble(); //ask the user for the scale of the temperature System.out.println("Is that Fahrenheit (F) or Celsius (C)?"); char choice = scnr.next().charAt(0); if(choice == 'F') { //convert to Celsius if given temperature was Fahrenheit System.out.println(temp + " degrees Fahrenheit is " + ((5.0/9) * (temp-32)) + " degrees Celsius"); } else {...
Fix this program package chapter8_Test; import java.util.Scanner; public class Chapter8 { public static void main(String[] args) { int[] matrix = {{1,2},{3,4},{5,6},{7,8}}; int columnChoice; int columnTotal = 0; double columnAverage = 0; Scanner input = new Scanner(System.in); System.out.print("Which column would you like to average (1 or 2)? "); columnChoice = input.nextInt(); for(int row = 0;row < matrix.length;++row) { columnTotal += matrix[row][columnChoice]; } columnAverage = columnTotal / (float) matrix.length; System.out.printf("\nThe average of column %d is %.2f\n", columnAverage, columnAverage); } } This program...
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in); System.out.print("In:"); int nn = inp.nextInt(); int n0, n1, n2, n3, n4; //Change only the code below //Set n0, n1, . . . n4 to each digits in nn by replacing //the blanks _A_, _B_, ect //Hint: the ones digit of 1234 is 1234%10 // the hundredth digit of 31415 is (31415/100)%10 n0 = _A_; n1 = _B_; n2 = _C_; n3 = _D_;...
import java.util.Scanner; public class SCAN { public static void main(String[ ] args) { int x, y, z; double average; Scanner scan = new Scanner(System.in); System.out.println("Enter an integer value"); x = scan.nextInt( ); System.out.println("Enter another integer value"); y = scan.nextInt( ); System.out.println("Enter a third integer value"); z = scan.nextInt( ); average = (x + y + z) / 3; System.out.println("The result of my calculation is " + average); } } What is output if x = 0, y = 1 and...
Given main(). define the Artist class (in file Artist java) with constructors to initialize an artist's information, get methods, and a printlnfo() method. The default constructor should initialize the artist's name to "None' and the years of birth and death to 0. printinfo() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise. Define the Artwork class (in file Artwork.java) with constructors to initialize an artwork's information, get methods, and a printinfo() method. The constructor should...
import java.util.Scanner; public class TwelveDays { public static void main(String[] args) { final int MAX = 12; int lastDay = 0; //last day for the song, user will update Scanner scan = new Scanner(System.in); //Get the last day and use input validation //Begin 1st while { } int day = 1; //loop control variable for song verses //Begin 2nd while { //Output: "On the" + day...
import java.util.Scanner; public class MPGMain { public static void main(String[] args) { Scanner input = new Scanner(System.in); Mileage mileage = new Mileage(); System.out.println("Enter your miles: "); mileage.setMiles(input.nextDouble()); System.out.println("Enter your gallons: "); mileage.setGallons(input.nextDouble()); System.out.printf("MPG : %.2f",mileage.getMPG()); } } public class Mileage { private double miles; private double gallons; public double getMiles()...
import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables int creditScore; double loanAmount,interestRate,interestAmount; final double I_a = 5.56,I_b = 6.38,I_c = 7.12,I_d = 9.34,I_e = 12.45,I_f = 0; String instructions = "This program calculates annual interest\n"+"based on a credit score.\n\n"; String output; Scanner input = new Scanner(System.in);// for receiving input from keyboard // get input from user System.out.println(instructions ); System.out.println("Enter the loan amount: $"); loanAmount = input.nextDouble(); System.out.println("Enter the credit score: "); creditScore...
Write a statement that outputs variable numTickets. End with a newline. import java.util.Scanner; public class VariableOutput ( public static void main (String D args) int numTickets; Scanner scnr new Scanner(System.in) scnr.nextint0:I/ Program will be tested with values: 15, 40. numTickets / Your solution goes here/