Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Change maker. Write a program to simulate operation of a cash register: your pro

ID: 3668876 • Letter: C

Question

Change maker. Write a program to simulate operation of a cash register: your program will prompt the user for the total cost of the purchase and the amount tendered (how much money the customer gives); then it will display the amount of change as well as how many dollar bills, quarters, dimes, nickels, and pennies should be given in change. Display this information in a we 11-formatted table. Dice game. Write a program that plays a simple dice game with the user. First, the computer rolls two dice and displays the result (e.g. "6 and 2"). The user is then asked to decide whether they bet high or low; two dice are rolled again and the user wins, loses, or ties based on what they chose and how the new roll compares to the old. (For example, if the first roll was 6/2, the user chose high, and the next roll is 3/4, the user loses because 7 is not higher than 8.) C++ Warriors. In a certain video game, your score at the end of a level is based on three numbers: how many enemies you KOed, how much damage you took, and how long it took to complete the level. In each of the three categories you can earn an A, B, or C rank, and there is also an overall rank based on an average of the three. Write a program that prompts the user to enter their number of KOs, damage, and time taken (in "minutes:second" form, e.g. "12:37") and displays the rank in each category as well as the overall rank in a table. To decide ranks: Enemies KOed: an A rank requires at least 1500 KOs; a B rank is awarded if there were fewer than 1500 but at least 1000; otherwise it is a C rank. Damage taken: A rank requires less than 1000 damage taken; B rank is at least 1000 but less than 3000; C rank otherwise, o Time taken: A rank if less than 15 minutes; B rank if more than 15 minutes but less than 25; C rank otherwise, o Overall rank: compute the average of the three category ranks (with A being 1, B being 2, and C being 3), rounded down.

Explanation / Answer

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package calcweightedavg;

import java.util.Random;
import java.util.Scanner;

/**
*
* @author Shivakumar
*
*/

public class CalcWeightedAvg {
static int re;
Random r=new Random();
int computerDice()
{
int f,s,c;

f=r.nextInt(6);
s=r.nextInt(6);
c=f+s;
re=c;
return c;
}
String playGame(int c,String str)
{
int f,s;
String result="";
f=r.nextInt(6);
s=r.nextInt(6);
c=f+s;
switch(str)
{
case "a":

if(re<c)
result="You Won";
else
result="Computer Won";

case "l":

if(re<c)
result="You Lose";
else
result="You Won";

}
return result;
  
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
CalcWeightedAvg v=new CalcWeightedAvg();
System.out.println("Lets play the Dice Game");
System.out.println("Computer dice value sum of 2 values is"+v.computerDice());
  
System.out.println("Enter a to bet above or l for lower the value");
v.playGame(re, sc.nextLine());
  
}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote