# DAT210 Data Programming Languages

Need Help in DAT/210 Java Assignments?
We provide help for students all over the world.

Items 1 to 10 of 18 total

per page
Page:
1. ## DAT/210 Week 2 Java LAB 3.18: Driving costs

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 2 Java LAB 3.18: Driving costs

Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 20 miles, 75 miles, and 500 miles.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
System.out.printf("%.2f", yourValue);
The output ends with a newline.

Ex: If the input is:
20.0 3.1599
the output is:
3.16 11.85 79.00

Note: Real per-mile cost would also include maintenance and depreciation.

import java.util.Scanner;

public class LabProgram {
public static void main(String() args) {
/* Type your code here. */
}
}

2. ## DAT/210 Week 2 Java LAB 3.19: Exact change

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 2 Java LAB 3.19: Exact change

Write a program with total change amount in pennies as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies.

Ex: If the input is:
0
the output is:
No change

Ex: If the input is:
45
the output is:
1 Quarter
2 Dimes

import java.util.Scanner;

public class LabProgram {
public static void main(String() args) {
/* Type your code here. */
}
}

3. ## DAT/210 Week 2 Java LAB 3.20: Smallest number

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 2 Java LAB 3.20: Smallest number

Write a program whose inputs are three integers, and whose output is the smallest of the three values.

Ex: If the input is:
7 15 3
the output is:
3

import java.util.Scanner;

public class LabProgram {
public static void main(String() args) {
/* Type your code here. */
}
}

4. ## DAT/210 Week 2 Java LAB 3.21: Interstate highway numbers

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 2 Java LAB 3.21: Interstate highway numbers

Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. Auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. Thus, I-405 services I-5, and I-290 services I-90.
Given a highway number, indicate whether it is a primary or auxiliary highway. If auxiliary, indicate what primary highway it serves. Also indicate if the (primary) highway runs north/south or east/west.

Ex: If the input is:
90
the output is:
I-90 is primary, going east/west.

Ex: If the input is:
290 the output is:
1-290 is auxiliary, serving 1-90, going east/west.

Ex: If the input is:
0
or any number not between 1 and 999,
the output is:
0 is not a valid interstate highway number.

import java.util.Scanner;

public class LabProgram {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int highwayNumber;
int primaryNumber;

highwayNumber = scnr.nextInt();

/* Type your code here. */
}
}

5. ## DAT/210 Week 3 Java LAB 4.13: Varied amount of input data

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 3 Java LAB 4.13: Varied amount of input data

Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics.

Ex When the input is:
15 20 0 5 -1
the output is:
10 20
You can assume that at least one non-negative integer is input.

import java.util.Scanner;

public class LabProgram {
public static void main(String[] args) {
/* Type your code here. */
}
}

6. ## DAT/210 Week 3 Java LAB 4.14: Elements in a range

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 3 Java LAB 4.14: Elements in a range

Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Assume that the list will always contain fewer than 20 integers. That list is followed by two more integers representing lower and upper bounds of a range. Your program should output all integers from the list that are within that range (inclusive of the bounds). For coding simplicity, follow each output integer by a space, even the last one. The output ends with a newline.

Ex: If the input is:
5 25 51 0 200 33
0 50
then the output is:
25 0 33
(the bounds are 0-50, so 51 and 200 are out of range and thus not output).
To achieve the above, first read the list of integers into an array.

import java.util.Scanner;

public class LabProgram {
public static void main(String[] args) {
/* Type your code here. */
}
}

7. ## DAT/210 Week 3 Java LAB 4.15: Word frequencies - methods

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 3 Java LAB 4.15: Word frequencies - methods

Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with an integer indicating the number of words that follow. Assume that the list will always contain less than 20 words.

Ex If the input is:
5 hey hi Mark hi mark
the output is:
hey 1
hi 2
Mark 1
hi 2
mark 1
Hint: Use two arrays, one for the strings, another for the frequencies.
Your program must define and call a method:
public static int getFrequencyOfWord(String[] wordsList, int listSize, String currWord)
Note: This is a lab from a previous chapter that now requires the use of a method.

import java.util.Scanner;

public class LabProgram {

/* Define your method here */

public static void main(String[] args) {
/* Type your code here. */

}
}

8. ## DAT/210 Week 3 Java LAB 4.16: Parsing dates

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 3 Java LAB 4.16: Parsing dates

Complete main() to read dates from input, one date per line. Each date's format must be as follows: March 1, 1990. Any date not following that format is incorrect and should be ignored. Use the substring() method to parse the string and extract the date. The input ends with -1 on a line alone. Output each correct date as: 3/1/1990.

Ex: If the input is:
March 1, 1990
April 2 1995
7/15/20
December 13, 2003
-1
then the output is:
3/1/1990
12/13/2003

9. ## DAT/210 Week 3 Java LAB 4.17: Data File

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 3 Java LAB 4.17: Data File

A comma separated value (.csv) file has been included to be used for this program. Each line contains two values, a name and a number separated by a comma (except the first line, which contains the titles for the value types). The name is that of a writer and the number refers to the number of works the writer has written. Ex. Jane Austen,6. Each line is an entry and each entry number can be updated by identifying the associated name.

Once complete, the following program opens data file allWorks.csv and asks if the user wants to update entries or add new entries. All entries are stored in an array while being read in and updated. The program then writes the array to the file, overwriting the original contents. The following TODO sections must be completed.
• Locate an entry to be updated by name (use the Java String index0f() method)
• Add a new entry if the name isn't found in the file (give the entry a new number)
• Open file allWorks.csv for output
• Write contents of the array to allWorks.csv (original file is overwritten)

Ex If the input is:
y
J.K. Rowling
30
y
Elton John
y
62
n
and allWorks.csv originally contains:
Name,Number of Novels
Jane Austen,6
Charles Dickens,20
Ernest Hemingway,9
Jack Kerouac,22
F. Scott Fitzgerald,8
Mary Shelley,7
Charlotte Bronte,5
Mark Twain,11
Agatha Christie,73
Ian Flemming,14
J.K. Rowling,14
Stephen King,54
Oscar Wilde,l

the output in all Works.csv is:
Name,Number of Novels
Jane Austen,6
Charles Dickens,20
Ernest Hemingway, 9
Jack Kerouac,22
F. Scott Fitzgerald,8
Mary Shelley,7
Charlotte Bronte,5
Mark Twain,11
Agatha Christie,73
Ian Flemming,14
J.K. Rowling,30
Stephen King,54
Oscar Wilde,l
Elton John,62

10. ## DAT/210 Week 4 Python LAB 5.20: Simple statistics

Regular Price: \$7.00

Special Price: \$3.00

DAT/210 Week 4 Python LAB 5.20: Simple statistics

Given 4 floating-point numbers. Use a string formatting expression with conversion specifiers to output their product and their average as integers (rounded), then as floating-point numbers.
Output each rounded integer using the following:
print( '{:.0F}'.format(your_value))
Output each floating-point value with three digits after the decimal point, which can be achieved as follows:
print( '{:.3F}'.format(your_value))

Ex: If the input is:
8.3
10.4
5.0
4.8
the output is:
2072 7
2071.680 7.125

main.py
numl = float(input())
num2 = float(input())
num3 = float(input())
num4 = float(input())
''' Type your code here. '''