Credit Cards
Credit card numbers follow patterns.
Given that a number has satisfied the above criteria A and B the following steps are taken to validate the number:
Given the number:
4388576018402626
The steps 1 - 5 above would be (after determining that A an B above have been satisfied):
Step 1:
2 * 2 = 4
2 * 2 = 4
4 * 2 = 8
1 * 2 = 2
6 * 2 = 12 ( 1 + 2 = 3)
5 * 2 = 10 (1 + 0 = 1)
8 * 2 = 16 (1 + 6 = 7)
4 * 2 = 8
Step 2:
4 + 4 + 8 + 2 + 3 + 1 + 7 + 8 = 37
Step 3:
6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38
Step 4:
37 + 38 = 75
Step 5:
75 % 10
You are to write a program that will prompt the user to enter a card number. You are then to determine if the number entered is valid or not. You are then to print to the screen if the number entered is a valid credit card number or not.
Your are to complete this program using functions. You are to have a function main in which you will only call the functions you have developed. The last line of your code is to be a call to main as below:
main()
Here are some valid numbers for testing purposes:
|
American Express |
378282246310005 |
|
American Express |
371449635398431 |
|
Discover |
6011111111111117 |
|
Discover |
6011000990139424 |
|
MasterCard |
5555555555554444 |
|
MasterCard |
5105105105105100 |
|
Visa |
4111111111111111 |
|
Visa |
4012888888881881 |
|
Visa |
4222222222222 |
Done in Python Format please
In: Computer Science
Write a program that prompts the user for a file name, make sure the file exists and then reads through the file, counts the number of times each word appears and outputs the word count in a sorted order from high to low.
The program should:
the - 7
in - 6
to - 5
and - 4
of - 4
File Name: NYT2.txt
File Content:
Fact-Checking Trump’s Orlando Rally: Russia, the Wall and Tax Cuts President Trump delivered remarks in Florida in a formal start to his re-election effort. Deutsche Bank Faces Criminal Investigation for Potential Money-Laundering Lapses Federal authorities are focused on whether the bank complied with anti-money-laundering laws, including in its review of transactions linked to Jared Kushner. Five NY1 Anchorwomen Sue Cable Channel for Age and Gender Discrimination The women, including Roma Torre, say their careers were derailed after Charter Communications bought New York’s hometown news station in 2016. Hypersonic Missiles Are Unstoppable. And They’re Starting a New Global Arms Race. The new weapons — which could travel at more than 15 times the speed of sound with terrifying accuracy — threaten to change the nature of warfare. Nxivm’s Keith Raniere Convicted in Trial Exposing Sex Cult’s Inner Workings Mr. Raniere set up a harem of sexual “slaves” who were branded with his initials and kept in line by blackmail. Jamal Khashoggi Was My Fiancé. His Killers Are Roaming Free. Washington hasn’t done enough to bring the murdered Saudi columnist’s killers to justice.
In: Computer Science
If the value of semaphore is negative, ___?
A. an increment operation can be perform on it.
B. a process is waiting forever.
C. there will be no process waiting on that semaphore.
D. a decrement can be perform on it.
((( ( can negative semaphore decreases in case of more waiting processes? Explain in details. )))
In: Computer Science
In a file called LengthSum.java, write a program that:
For example: if the user enters strings "UT" and "Arlington", your program output should look EXACTLY like this:
Please enter a string: UT Please enter a second string: Arlington The first string has length 2. The second string has length 9. The sum of the two lengths is 11.
Your program's output should match EXACTLY the format shown above. There should be no deviations, no extra spaces or lines, no extra punctuation in your output. What you see above as uppercase letters should remain uppercase in your output, what you see as lowercase letters should remain as lowercase in your output, what you see as spaces and punctuation should remain exactly as spaces and punctuation in your output.
In: Computer Science
Explain the two different categories of Application layer protocols, and then detail the PDU used at this layer.
In: Computer Science
How can you prevent damage to a component prior to touching it?
In: Computer Science
Write a Java program (single file/class) whose filename must be Numbers.java. The program reads a list of integers from use input and has the following methods: 1. min - Finds the smallest integer in the list. 2. max- Finds the largest integer in the list. 3. average - Computes the average of all the numbers. 4. main - method prompts the user for the inputs and ends when the user enter Q or q and then neatly outputs the entire list of entries on one line and then the minimum, maximum, and average. values on separate lines with nice readable labels. 5. Make sure your code runs without error and handles bad inputs and 0 and negative numbers are valid. 6. Followed instructions and include to get full credit file must include your name, date, class and Javadoc code comments for each and every method as well as logic comments.m
In: Computer Science
Java program
Create class DateClass with the following capabilities:
Output the date in multiple formats, such as
MM/DD/YYYY June 14, 1992 DDD YYYY
Use overloaded constructors to create DateClass objects initialized with dates of the formats in part (a). In the first case the constructor should receive three integer values. In the second case it should receive a String and two integer values. In the third case it should receive two integer values, the first of which represents the day number in the year.
If someone enters the day as the 14 and the month is june, the program should be able to convert that to the day out of 365 for the third format. No null values. The program should convert whatever the user enters and print out all three date formats correctly.
In: Computer Science
Task #3 Experimenting with an array of random integers (Week
2)
Make sure that the following 3 experiments are done repeatedly by
generating a new set of integers to fill the array. For this
iterate 10 times and observe results for consistency.
• Make the array size reasonably large (say a thousand) and an even
number.
• Choose the version of nextInt() that allows you to set a cap on
the random integers generated (set it to a few thousands, but way
less than the maximum integer).
• Do the following experiments:
o Count how many integers in the array are odd and even. Are the
odd and even counts almost equal?
o Find the minimum, maximum, and average of the integers in the
array. Keep track of the minimum and maximum of the three
quantities across runs.
o Sort the array by writing an inner and an outer loop. Count the
number of times you needed to swap integers.
In: Computer Science
Using Java
Write only “stubs” for methods in the Figure, Rectangle, and Triangle classes:
Consider a graphics system that has classes for various figures — say, rectangles, boxes, triangles, circles, and so on. For example, a rectangle might have data members’ height, width, and either a center point or upper-left corner point, while a box and circle might have only a center point (or upper-right corner point) and an edge length or radius, respectively. In a well-designed system, these would be derived from a common class, Figure. In this homework assignment, you will implement such a system.
The class Figure is an abstract base class. In this class, create abstract methods for draw, erase, center, equals, and toString.
Add Rectangle and Triangle classes derived from Figure. Each class has stubs for methods erase, draw, and center. In these "stubs", the method simply prints a message telling the name of the class and which method has been called in that class. Because these are just stubs, they do nothing more than output this message. The method center calls the erase and draw methods to erase the object at its current location and redraw the figure at the center of the picture being displayed. Because you have only stubs for erase and draw, center will not do any real “centering” but simply will call the methods erase and draw, which will allow you to see which versions of draw and center it calls. Add an output message in the method center that announces that center is being called. The methods should take no arguments.
Define a demonstration program for your classes which contains main. Test your programs:
In main, make sure that you tell the user what's going on at each step.
Your output should consist primarily of messages from your stub methods. An example of the output from your program might be the following (note: output from main method is shown below in italics):
** Create 2 triangles ** Entering Figure Constructor for triangle 0 Running Triangle constructor for triangle 0 Entering Figure Constructor for triangle 1 Running Triangle constructor for triangle 1 ** Create 2 rectangles ** Entering Figure Constructor for rectangle 0 Running Rectangle constructor for rectangle 0 Entering Figure Constructor for rectangle 1 Running Rectangle constructor for rectangle 1 ** Draw both triangles ** Entering draw() method for Triangle 0 Entering draw() method for Triangle 1 ** Draw both rectangles ** Entering draw() method for Rectangle 0 Entering draw() method for Rectangle 1 ** Center one triangle ** Entering center() method for Triangle 0 center() calling erase() Entering erase() method for Triangle 0> center() calling setCenter() to reset center. Entering Figure's setCenter() for figure 0 center() calling draw() Entering draw() method for Triangle 0 ** Center one rectangle ** Entering center() method for Rectangle 1 center() calling erase() Entering erase() method for Rectangle 1 center() calling setCenter() Entering Figure's setCenter() for figure 1 center() calling draw() Entering draw() method for Rectangle 1 |
In: Computer Science
you are required to use only the functional features of Scheme; functions with an exclamation point in their names (e.g., set!) and input/output mechanisms other than load and the regular read-eval-print loop are not allowed. (You may find imperative features useful for debugging. That’s ok, but get them out of your code before you hand anything in.)
Write a function minMax that, given a list of integers, returns a tuple containing the smallest and largest element in the list. Just return (0 0) for the empty list. > (minMax (5 4 3 2 1)) (1 5)
using the programming language scheme
In: Computer Science
Assume the following JavaScript program was interpreted using static-scoping rules. What value of x is displayed in function sub1? Under dynamic-scoping rules, what value of x is displayed in function sub1?
var x;
function sub1() {
document.write("x = " + x + "");
}
function sub2() {
var x;
x = 10;
sub1();
}
x = 5;
sub2();In: Computer Science
Enter a number (0-6): 2
** 2 is Tue **
!!! NO if-else conditions
In: Computer Science
Modify the mortgage program to display 3 mortgage loans: 7 years at 5.35%, 15 year at 5.5%, and 30 years at 5.75%. Use an array for the different loans. Display the mortgage payment amount for each loan. Do no use graphical user interface. Insert comments in the program to document the program.
***********Please look at my code so far. Still having trouble with arrays. Want to know if I'm going the right path********
import java.util.Scanner;
public class MortPay2
{
public static void main(String args[])
{
//declaration section
double principal, monthlyPayment;
int choice;
Scanner input = new Scanner(System.in);
int term [] = {84, 180, 360}; //term in
months
double rate [] = {.0044, .0046, .0048};//rate in
decimal format
//display section
System.out.println("Please select from 3 loan
options.");
System.out.println("1. Loan 1: 7 year term at 5.35%
interest.");
System.out.println("2. Loan 2: 15 year term at 5.5%
interest.");
System.out.println("3. Loan 3: 30 year term at 5.75%
interest.");
choice = input.nextInt();
if (choice ==1)
{
System.out.println("You have chosen
Loan 1.");
System.out.println("Please enter
the loan amount: $");
principal = input.nextDouble();
for ( int i = 0; i<3;
i++)
{
monthlyPayment =
principal * rate[0] / (1.0 - Math.pow (rate[0] + 1),
-term[0]));
System.out.println("Total monthly mortgae payment is $%.2f%n",
monthlyPayment);
}
}
}
}
In: Computer Science
Problem: Implement a class named StringParser, along with specified methods, that can read words from a text file, parse those words (such as finding palindromes), and write those words to a new file More specifically: 1. Write the StringParser class so that it has the following methods: a) public static void main(String[] args) -- The main driver of the program. Prompts the user for an input file, an output file, and a choice for what kinds of words to output. b) public static void rawOutput(File in, File out)-- Parses an input file, writing each word from the input on a separate line in the output file. c) public static void palindromeOutput(File in,File out) -- Parses an input file, writing only the palindromes to the output file, in alphabetical order, one line at a time, without repetition. Palindromes are words that read the same forward and backward, ignoring digits and punctuation. d) public static void hundredDollarWordOutput(File in, File out) -- Parses an input file, writing only the $100 words to the output file, in alphabetical order, one line at a time, in uppercase, without repetition. $100 words are found by assigning $1 to A, $2 to B, and so on. For example ELEPHANTS is a $100 word because: E + L + E + P + H + A + N + T + S is 5 + 12 + 5 + 16 + 8 + 1 + 14 + 20 + 19 = 100 e) public static boolean isPalindrome(String word) -- Determines if a word is a palindrome (reads the same forward and backward). The method is case-sensitive, so it will say that dad and DAD and d-a-d are palindromes, but Dad and d-ad are not palindromes. f) public static String cleanup(String word)-- Takes a string and removes all non-letters, returning an all uppercase version. For example, this input: "A man, a plan, a canal. Panama." will produce this output: "AMANAPLANACANALPANAMA" g) public static int wordValue(String word)-- Returns the monetary value of a word, found by assigning the value $1 to A, $2 B, and so on, up to $26 for Z. The method will ignore differences in case, so both A and a are each worth $1. It will also ignore any non-letters in the input. 2. Create your own input test file, and use it with your code to generate three output files. 3. Upload all five files (Java source code, input file, three output files).
In: Computer Science