public class Program7 { publicstaticvoidmain(String[]args){ int[]numbers=newint[100]; String[]names={"Maria","Aris","Galin","Galena"}; double[]balances=newdouble[]{2,56,12.57,36.57,57.89}; //length System.out.println(numbers.length); System.out.println(names.length); System.out.println(balances.length); //modifying names[3]="Celine Dion"; System.out.println("__________________________"); //looping for(inti=0;i
public class Program7 {
publicstaticvoidmain(String[]args){
int[]numbers=newint[100];
String[]names={"Maria","Aris","Galin","Galena"};
double[]balances=newdouble[]{2,56,12.57,36.57,57.89};
//length
System.out.println(numbers.length);
System.out.println(names.length);
System.out.println(balances.length);
//modifying
names[3]="Celine Dion";
System.out.println("__________________________");
//looping
for(inti=0;i<names.length;i++){
System.out.println(names[i]);
}
System.out.println("__________________________");
for(Stringname:names){
System.out.println(name);
}
//modifying array
System.out.println("__________________________");
for(inti=0;i<names.length;i++){
names[i]=names[i]+" Annan";
System.out.println(names[i]);
}
System.out.println("__________________________");
doubletotal=0.0;
for(inti=0;i<balances.length;i++){
total+=balances[i];
}
System.out.println("Total Balance: "+ total);
}
}
//calculate the average of the total balance
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images