700 2nd 8-Week spring 2018 Exam # 1 Name 1. Desig n a program that asks the user
ID: 3704547 • Letter: 7
Question
700 2nd 8-Week spring 2018 Exam # 1 Name 1. Desig n a program that asks the user to enter the dollar amount of the opening balance of an account. Then the program should ask the user to enter amount of deposits to the account. Use the sum to add t Next, ask the user to enter the dollar amount of withdrawals from the account d the dollar this amount to the balance uring the last month. Use the sum to subtract this from the balance. The program should then display the closing balance in the account 2. Design a program that asks the user to enter a student's grades on four exams. The ram should display the four grades and the average of the four grades, First prog grade is %10, second grade is %20, third grade is %25and the fourth grade is 9630 of the total grade. To add the grades, use a variable called total grade, which you should initialize to zero. A bank teller needs a program to total the amount of money in his coin tray. Design a program that asks the user to enter the number of each dollars, coins in dollars and cents. 3. type of U.S. coin (half quarters, nickels, dimes, and pennies) and that displays the total value of the ram that asks the user to enter the price of an item and the sales tax ate as a percent. The program should display the total price of the item (price plus tax). After obtaining the input from the user, the program should calculate the 4. Design a prog total price of the item using the equivalent of the following formula: price = price * (1 sales-tax-rate) + te telephone bills for the local telephone company. Each customer has a of 12.95 per month and gets charged extra for each local call and each long-distance t the user for the number of local calls made during the month. The call is $0.10. Use the+operator to add the cost of the local calls to the total 5. Write a program to compu base charge call. The program should prompt ram should prompt the user for the total charge for long-distance calls made during theoperator to add the long-distance charges to the total bill. Finally, the program bill. Then t the month. should calculate the tax on the the of the total bill. The tax rate is 8.72% use . z operator to add the tax to total bill by m local calls, the cost of the long distance calls, the tax, and the total bilExplanation / Answer
1. public class Account{
public static void main(String[] args) {
double amount=0,deposits=0,withdrawl=0;
Scanner scanner = new Scanner(System.in);
System.out.println("enter dollar amount of opening balance of the account :");
amount = scanner.nextDouble();
System.out.println("enter dollar amount of deposits to the accounts : ");
deposits=scanner.nextDouble();
amount=amount+deposits;
System.out.println("enter dollar amount of withdrawls from the accounts : ");
withdrawl=scanner.nextDouble();
if(withdrawl>amount) {
System.out.println("Sorry !! Not enough balance to withdraw");
}
else {
amount=amount-withdrawl;
System.out.println("Closing Balance of the account : "+ amount);
}
scanner.close();
}
}
2. public class Grade{
public static void main(String[] args) {
double grade1=0,grade2=0,grade3=0,grade4=0,total_grade=0,avg_grade=0;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter Grades in four exams :");
grade1=scanner.nextDouble();
grade2=scanner.nextDouble();
grade3=scanner.nextDouble();
grade4=scanner.nextDouble();
total_grade=grade1+grade2+grade3+grade4;
grade1=(total_grade*10/100);
grade2=(total_grade*20/100);
grade3=(total_grade*25/100);
grade4=(total_grade*30/100);
System.out.println("grade1: "+grade1);
System.out.println("grade2: "+grade2);
System.out.println("grade3: "+grade3);
System.out.println("grade4: "+grade4);
avg_grade=(grade1+grade2+grade3+grade4)/4;
System.out.println("average Grade: "+avg_grade);
scanner.close();
}
}
3. public class DollarSum {
public static void main(String[] args) {
int halfDollars=0,quarters=0,nickels=0,dimes=0,pennies=0;
int totalcents=0;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter No of halfDollars :");
halfDollars=scanner.nextInt();
System.out.println("Enter No of quarters :");
quarters=scanner.nextInt();
System.out.println("Enter No of nickels :");
nickels=scanner.nextInt();
System.out.println("Enter No of dimes :");
dimes=scanner.nextInt();
System.out.println("Enter No of pennies :");
pennies=scanner.nextInt();
totalcents=(halfDollars*50)+(quarters*25)+(nickels*5)+(dimes*10)+pennies;
System.out.println(totalcents);
System.out.println("Total :"+totalcents/100+" dollars "+totalcents%100+" cents");
scanner.close();
}
}
4. public class DollarSum {
public static void main(String[] args) {
double price=0,salesTax=0;
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the price of item :");
price=scanner.nextDouble();
System.out.println("Enter the sales tax in percent :");
salesTax=scanner.nextDouble();
salesTax=salesTax/100;
price=price*(1+salesTax);
System.out.println("Total Price of Item : "+price);
scanner.close();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.