[code=java]import java.util.Scann er;
public class Program01C
{
public static void main(String[] args)
{
double purchase, totalTax, salesTax, countyTax, total;
salesTax = 0.04;
countyTax = 0.02;
Scanner keyboard = new Scanner(System. in);
System.out.prin t("Enter the amount of purchase: ");
purchase = keyboard.nextIn t();
totalTax = (salesTax + countyTax);
total = (((totalTax) * purchase) + purchase);
System.out.prin tln("Sales Tax:" + salesTax + "\nCounty Tax:" + countyTax + "\nTotal Sales Tax:" + totalTax + "\nTotal Purchase:" + purchase + "\nTotal Amount of Purchase:" + total);
I want to add precision to total variable at the end of the program by 2, but forgot how to do it:
"\nTotal Amount of Purchase:" + total);
Thanx, Paradox(>")>
Question num# 2:
import java.util.Scann er;
public class Program01B
{
public static void main(String[] args)
{
double testScore01, testScore02, testScore03, totalAverage, totalAveragemod ;
Scanner keyboard = new Scanner(System. in);
System.out.prin t("Enter Test Score 1:");
testScore01 = keyboard.nextIn t();
System.out.prin t("Enter Test Score 2:");
testScore02 = keyboard.nextIn t();
System.out.prin t("Enter Test Score 3:");
testScore03 = keyboard.nextIn t();
//Division of 3 testscores plus remainder(Modul us)
totalAverage = ((testScore01 + testScore02 + testScore03) / 3);
totalAveragemod = ((testScore01 + testScore02 + testScore03) % 3);
System.out.prin tln("Test Score 1:" + testScore01 + "\nTest Score 2:" + testScore02 + "\nTest Score 3:" + testScore03 + "\nTotal Average of Test Scores:" + totalAverage + "." + totalAveragemod );
}
}
[/code]
The modulus outputs as so:
Enter Test Score 1:80
Enter Test Score 2:90
Enter Test Score 3:80
Test Score 1:80.0
Test Score 2:90.0
Test Score 3:80.0
Total Average of Test Scores:83.33333 333333333.1.0
How can I make so it outputs in decimal form(00.00) or if it needs to have precision added to it then ok, but it has 3 decimal places so IDK!
Thanx, Paraodx(>")>
public class Program01C
{
public static void main(String[] args)
{
double purchase, totalTax, salesTax, countyTax, total;
salesTax = 0.04;
countyTax = 0.02;
Scanner keyboard = new Scanner(System. in);
System.out.prin t("Enter the amount of purchase: ");
purchase = keyboard.nextIn t();
totalTax = (salesTax + countyTax);
total = (((totalTax) * purchase) + purchase);
System.out.prin tln("Sales Tax:" + salesTax + "\nCounty Tax:" + countyTax + "\nTotal Sales Tax:" + totalTax + "\nTotal Purchase:" + purchase + "\nTotal Amount of Purchase:" + total);
I want to add precision to total variable at the end of the program by 2, but forgot how to do it:
"\nTotal Amount of Purchase:" + total);
Thanx, Paradox(>")>
Question num# 2:
import java.util.Scann er;
public class Program01B
{
public static void main(String[] args)
{
double testScore01, testScore02, testScore03, totalAverage, totalAveragemod ;
Scanner keyboard = new Scanner(System. in);
System.out.prin t("Enter Test Score 1:");
testScore01 = keyboard.nextIn t();
System.out.prin t("Enter Test Score 2:");
testScore02 = keyboard.nextIn t();
System.out.prin t("Enter Test Score 3:");
testScore03 = keyboard.nextIn t();
//Division of 3 testscores plus remainder(Modul us)
totalAverage = ((testScore01 + testScore02 + testScore03) / 3);
totalAveragemod = ((testScore01 + testScore02 + testScore03) % 3);
System.out.prin tln("Test Score 1:" + testScore01 + "\nTest Score 2:" + testScore02 + "\nTest Score 3:" + testScore03 + "\nTotal Average of Test Scores:" + totalAverage + "." + totalAveragemod );
}
}
[/code]
The modulus outputs as so:
Enter Test Score 1:80
Enter Test Score 2:90
Enter Test Score 3:80
Test Score 1:80.0
Test Score 2:90.0
Test Score 3:80.0
Total Average of Test Scores:83.33333 333333333.1.0
How can I make so it outputs in decimal form(00.00) or if it needs to have precision added to it then ok, but it has 3 decimal places so IDK!
Thanx, Paraodx(>")>
Comment