
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);
}
}
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Fix this program package chapter8_Test; import java.util.Scanner; public class Chapter8 { public static void main(String[] args)...
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 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()...
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; 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...
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
}
Write a Java program where the main () method prompts the user to select an integer value between 1 and...
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...
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 Client{ public static void main(String args[]){ Coin quarter = new Coin(25); Coin dime = new Coin(10); Coin nickel = new Coin(5); Scanner keyboard = new Scanner(System.in); int i = 0; int total = 0; while(true){ i++; System.out.println("Round " + i + ": "); quarter.toss(); System.out.println("Quarter is " + quarter.getSideUp()); if(quarter.getSideUp() == "HEADS") total = total + quarter.getValue(); dime.toss(); System.out.println("Dime is " + dime.getSideUp()); if(dime.getSideUp() == "HEADS") total = total +...
import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 { public static void main(String[] args) { String name; String answer; int correct = 0; int incorrect = 0; Scanner phantom = new Scanner(System.in); System.out.println("Hello, What is your name?"); name = phantom.nextLine(); System.out.println("Welcome " + name + "!\n"); System.out.println("My name is Danielle Brandt. " +"This is a quiz program that...
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...