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 {...
import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String inputMonth; int inputDay; inputMonth = scnr.nextString(); inputDay = scnr.nextInt(); String season; if(inputMonth == "April","May","June"){ String season = "Spring"; }else if(inputMonth == "July","August","September"){ String season = "Summer"; }else if(inputMonth == "October","November","December"){ String season = "Autumn"; }else if(inputMonth == "January","February","March"){ System.out.println("Winter"); }else{ System.out.println("Invalid"); } if((inputMonth == "March") && (inputDay >= 20)){ String season = "Spring"; }else if((inputMonth == "June") && (inputDay >= 21)){...
import java.util.Scanner; public class SieveOfEratosthenes { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter a number"); int num = sc.nextInt(); boolean[] bool = new boolean[num]; for (int i = 0; i< bool.length; i++) { bool[i] = true; } for (int i = 2; i< Math.sqrt(num); i++) { if(bool[i] == true) { for(int j = (i*i); j<num; j = j+i) { bool[j] = false;...
import java.util.Scanner; public class Age { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a; System.out.println("Input your age"); a = sc.nextInt(); boolean mess = isAllowed(a); String mess2 = ?isAllowed(a)return"You are allowed to vote";:"You arent allowed"; String age = personAge(a); personAge(a); } public static String personAge(int age) { String mess = ""; if(age<18) return mess = "You are minor"; else if(age>=18 && age<=22) return mess = "You are legal you can vote"; else if(age>=22 && age<=60) return...
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...
Consider the following sample program: import java.util.Scanner; public class Palindrome { public static void main(String[] args){ Scanner kb = new Scanner(System.in); System.out.println("Enter a word:"); String word = kb.next(); String reverse = ""; for (int i=word.length()-1; i>=0; i--) reverse += word.charAt(i); boolean result = reverse.equalsIgnoreCase(word); if (result) System.out.println("The word " +word+ " is a Palindrome."); else System.out.println("The word " +word+ " is not a Palindrome."); } } Rewrite the program so that the main method is: public static void...
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...