for java using the loop
Correct digits are assigned as follows:
Student: 1, 2 (means 1 or 2)
Teacher: 3, 4, 5
Secretary: 6
Others: 7, 8, 9
|
Number of pages |
1 to 10 |
10 to 20 |
>20 |
|
Students |
0.10 Dhs |
20% off |
40% off |
|
Teachers |
0.30 Dhs |
30% off |
40% off |
|
Secretaries |
0.20 Dhs |
25% off |
40% off |
|
Others |
0.60 Dhs |
10% off |
20% off |
please do upvote.If you have any problem do comment and i shall be happy to help you.Thanks for using HomeworkLib.
------------------------------------------
import java.util.Scanner;
public class PhotoCopier
{
public static void main(String args[])
{
//get input
while(true)
{
Scanner read=new
Scanner(System.in);
System.out.println("Enter identification code or stop(to end):
");
String
code=read.next();
if(code.equalsIgnoreCase("stop"))
{
break;
}
int
fourth_digit=isValid(code);
if(fourth_digit!=-1)
{
System.out.println("Enter number of pages:
");
int pageCount=read.nextInt();
printCost(pageCount,fourth_digit);
}
else
{
System.out.println("invalid code");
}
}
}
private static void printCost(int pageCount,int
fourth_digit) {
// TODO Auto-generated method
stub
double cost=0;
//calculate cost according to
table
switch(fourth_digit)
{
case 1
: case 2:
if(pageCount<=10 )
{
cost=pageCount*0.1;
}
else
if(pageCount >10 && pageCount <=20)
{
cost=pageCount*0.1;
cost=cost-((20/100)*cost);
}
else
{
cost=pageCount*0.1;
cost=cost-((40/100)*cost);
}
break;
case 3: case 4 : case 5:
if(pageCount<=10 )
{
cost=pageCount*0.3;
}
else
if(pageCount >10 && pageCount <=20)
{
cost=pageCount*0.3;
cost=cost-((30/100)*cost);
}
else
{
cost=pageCount*0.3;
cost=cost-((40/100)*cost);
}
break;
case 6:
if(pageCount<=10 )
{
cost=pageCount*0.2;
}
else
if(pageCount >10 && pageCount <=20)
{
cost=pageCount*0.2;
cost=cost-((25/100)*cost);
}
else
{
cost=pageCount*0.1;
cost=cost-((40/100)*cost);
}
break;
case 7: case 8: case 9:
if(pageCount<=10 )
{
cost=pageCount*0.6;
}
else
if(pageCount >10 && pageCount <=20)
{
cost=pageCount*0.1;
cost=cost-((10/100)*cost);
}
else
{
cost=pageCount*0.1;
cost=cost-((20/100)*cost);
}
break;
default:
System.out.println("invalid page count");
break;
}
System.out.printf("cost is
%f",cost);
}
private static int isValid(String code) {
// TODO Auto-generated method
stub
int first_digit,second_digit,third_digit,fourth_digit;
//get digits from code
first_digit=Character.getNumericValue(code.charAt(0));
second_digit=Character.getNumericValue(code.charAt(1));
third_digit=Character.getNumericValue(code.charAt(2));
fourth_digit=Character.getNumericValue(code.charAt(3));
int sum=first_digit+second_digit+third_digit;
int remainder=sum%7;
//if valid return fourth
digit
if(remainder==fourth_digit)
{
return
fourth_digit;
}
return -1;//if not valid return
-1
}
}
---------------------------------------------

for java using the loop The department of History has just bought a new photocopier. Any...
The Language is for Java
------ Input -------
credit-cards-2.dat
//////////////////// Output////////////
Enter a filename\n
Credit card number: 3056 9309 0259 04\n
Checksum: 50\n
Card status: VALID\n
Credit card number: 3852 0000 0232 37\n
Checksum: 40\n
Card status: VALID\n
Credit card number: 6011 1111 1111 1117\n
Checksum: 30\n
Card status: VALID\n
Credit card number: 6011 0009 9013 9424\n
Checksum: 50\n
Card status: VALID\n
Credit card number: 3530 1113 3330 0000\n
Checksum: 40\n
Card status: VALID\n
Credit card number: 3566 0020 2036...
Write in java . I started it can you finish it. I will rate if
code works
What is this lab about and what will you be working on? In this lab, you will practice new tools and concepts you've learned in class and in lab. Namely this lab will be on methods, arrays (1D and 2D), and on repetition (using loops) In this lab, you will have to complete two activities. Here is what you have to do: Activity...
DO NOT USE ANY EXTERNAL LIBRARIES BESIDES BUILT IN JAVA
LIBRARIES! KEEP IT SIMPLE!!!
Provided Code:
import java.util.Scanner;
public class OddAndEven{
/* PART 1: Create a nonstatic method that takes in an int number
quantity (n) and returns a returns a
String of numbers from 0 to n (inclusive) as the example above
demonstrates. Call this quantityToString.
In this method you should check that n is between 0(inclusive) and
100(inclusive).
If n is outside these boundaries return and empty...
JAVA Lab -Lottery Calculator IMPORTANT: This lab is best implemented using a loop structure. If you implement this without a loop, you would need to run your program once for each test item. Create a java program that will test for winning numbers on a lottery game. Each lottery ticket will have 5 integer numbers. Valid numbers must be integer numbers between 1 and 55 Assume that the winning Lottery ticket is 1 9 15 33 40 Your program is...
Please I need help with this c++ code. please show all
steps , write comments and show sample runs. Thank you.
1. The Federal Bureau of Investigation (FBI) has recently changed its Universal Control Numbers (UCN) for identifying individuals who are in the FBI's fingerprint database to an eight-digit base 27 value with a ninth check digit. The digits used are: 0123456789ACDE FHJKLMNPRTVWX Some letters are not used because of possible confusion with other digits: B->8, G->C, I- >1, 0->0,...
Banks issue credit cards with 16 digit numbers. If you've never thought about it before you may not realize it, but there are specific rules for what those numbers can be. For example, the first few digits of the number tell you what kind of card it is - all Visa cards start with 4, MasterCard numbers start with 51 through 55, American Express starts with 34 or 37, etc. Automated systems can use this number to tell which company...
Please tell me whether my answers are correct or not. If not
please tell me why and give me a guide to solving the problem
correctly. Thanks!
3 Check Digits: ISBN In this problem, we'll look at a real-world applications of check-digits International Standard Book Numbers (ISBNS) are 10-digit codes (did2...dio) which are assigned by the publisher. These 10 digits contain information about the language, the publisher, and the number assigned to the book by the publisher. Additionally, the last...
I need it in c++ The U.S. Banking System The code assigned to a bank is an eight digit number plus a ninth check digit. To check for validity, the first eight digits are assigned weights (left to right) of 7, 3, and 9 repetitively. Each digit is multiplied by its weight and the products summed. The resulting sum (mod 10) should equal the check digit. The assigning of weights insures that all single digit errors and most transposition errors...
The first significant digit in any number must be 1, 2, 3, 4, 5, 6, 7, 8. or. It was discovered that first digits do not our with equal frequency Probabilities of occurrence to the first digit in a number are shown in the accompanying table. The probability distribution is now known as Benford's Law For example, the following dibution represents the first digits in 207 alegedly fraudulent checks written to a boa company by an employee attempting to embezzle...
JAVA LANGUAGE
int choice;
Scanner in = new Scanner(System.in);
while(true) {
System.out.println();
System.out.println("(1) Add a new flight.");
System.out.println("(2) Buy ticket.");
System.out.println("(3) Request a Check-In.");
In this assignment, you are required to improve your flight registration system. Your new system should be able to process check-in of passengers and calculate take-off load of planes. You should also use enums to represent menu items such as; (1)Add a new flight. (2)Buy ticket. (3)Request a Check-In. (4) Process a Check-In. (5) Display Valid...