In: Computer Science
8. Create a truth table and determine the results for the following equation and values
Equation : bool b = ((a+4< 7) || ((b-a > 10) && !(c*a == 8)))
Values : a = 2; b = 8; c = 4
9. Write a program using Atom and submit via Blackboard.
a. Request an integer whole dollar amount from the console.
b. Using the least amount of bills ($50,$20,$10,$5,$1) necessary, calculate how many of each bill type you will need to get to that value.
Output Example 1 (input is bold and italicized)
Enter a whole dollar amount as n integer: 633
You will need:
12 $50 bill(s).
1 $20 bill(s).
1 $10 bill(s).
0 $5 bills(s).
3 $1 bill(s).
Output Example 2 (input is bold and italicized)
Enter a whole dollar amount as an integer: 364
You will need:
7 $50 bill(s).
0 $20 bill(s).
1 $1 bill(s).
0 $5 bills(s).
4 $1 bills(s).
8) lets derive the expression part by part...
a=2;b=8;c=4;
a+4<7 => 6<7 => true
b-a > 10 =>8-2 > 10 => 6 > 10 => false
!(c*a==8) => !(4*2==8) => !(8==8) => !(true) => false
therefore the total expression comes : (true || (false && false)) =>( true || false) => true
therefpre,b=true;
9) As you have not mentioned the language, i am writing the code in java in a very simple way...
if you have any doubt, please ask me in the comment box...
code...
import java.util.*;
public class bill{
        public static void main(String args[]){
                int n;
                Scanner in = new Scanner(System.in);   //creating scanner object
                System.out.print("Enter a while dollar amount as n integer : ");
                n=in.nextInt();    //taking input say 633
                System.out.println("you will need :");
                System.out.println(n/50+"   $50 bill(s).");     //total $50 bill required is 633/50=12
                n=n%50;      // finding the rimainder i.e. for 633 it is 33 
                System.out.println(n/20+"   $20 bill(s).");    // then total $20 bill required is 33/20=1 
                n=n%20;       //now remainder is 33%20=13
                System.out.println(n/10+"   $10 bill(s).");   // total number of $10 bill required is 13/10=1
                n=n%10;        //now the n value is 13%10=3
                System.out.println(n/5+"   $5 bill(s).");   // total number of $5 bill required is 3/5=0
                n=n%5;    // now the value of n is 3%5=3
                System.out.println(n+"   $1 bill(s).");    //so finally $1 bill required is n
                }  //end  of main
        }  //end of class
I have done the code with one example... hope you will understand...
output...

