Cosc 205 Module 7 Assignment
Cosc 205 Module 7 Assignment
Cosc 205 Module 7 Assignment
Module 7 Task 1
import java.util.Scanner;
import java.lang.String;
Module 7 Task 2
import java.util.Scanner;
class module_7_assignment_task_2 {
public static void main(String args[]){
Scanner input= new Scanner(System.in);
int supplies [][] = new int[2][7];
int cost [][] = new int[2][7];
int totalCost = 0;
System.out.println("Please Enter your daily supply for 2 weeks");
for(int row = 0; row < 2; row++){
int week = row + 1;
for(int column = 0; column < 7; column++){
int day = column + 1;
System.out.printf ("supply for week %d day %d :",week,day);
int supply = input.nextInt();
int costDay = supply * 155;
supplies [row][column] = supply;
cost [row][column] = costDay;
totalCost += costDay;
}
System.out.print("\n");
}
System.out.println("The daily cost of the supplies are: ");
for(int row=0;row<2;row++){
int week=row+1;
for(int column=0;column<7;column++){
int day=column+1;
System.out.printf("Cost of supply for week %d day %d is: %d\n", wee
k, day, cost[row][column]);
}
System.out.print("\n");
}
System.out.printf("Total cost for the period is: %d", totalCost);
}
}
Module 7 Task 3
import java.util.Random;
import java.util.Scanner;
public class Task_3 {
Scanner input = new Scanner(System.in);
public static void main (String args[]) {
int sum_array = 0;
Random generator = new Random();
int [][] array = new int [10][10];
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
array [i][j] = generator.nextInt(100);
}
}
System.out.println("Numbers in the array are: \n");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
System.out.print(array [i][j] + " ");
}
System.out.print("\n");
}
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
sum_array = sum_array + array [i][j];
}
}
System.out.print("The total sum of numbers in the array is: " + sum_array)
;
}
}