.... How to Find Your Subject Study Group & Join ....   .... Find Your Subject Study Group & Join ....  

We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Study Groups By Subject code Wise (Click Below on your university link & Join Your Subject Group)

[ + VU Study Groups Subject Code Wise ]  [ + COMSATS Virtual Campus Study Groups Subject Code Wise ]

Looking For Something at vustudents.ning.com?Search Here

Question 1: Marks 10
Your job is to take code snippets from the pool and place them into the blank lines in the code. You
may use the same snippets more than once, and you won’t need to use all the snippets. Your goal is to
make a class that will compile and run and produce the output listed.
Output:
Code:
class Triangle {
double area;
int height;
int length;
public static void main(String [] args) {
____________
_______________________
while ( __________ ) {
__________________________
________.height = (x + 1) * 2;
________.length = x + 4;
__________________________
System.out.print(“triangle “+x+”, area”);
System.out.println(“ = “ + _______.area);
________________
}
______________
x = 27;
Triangle t5 = ta[2];
ta[2].area = 343;
System.out.print(“y = “ + y);
System.out.println(“, t5 area = “+ t5.area);
}
void setArea() {
____________ = (height * length) / 2;
}
}
Pool:
Question 2: Marks 10
Your job is to take code snippets from the pool and place them into the blank lines in the code. You
may not use the same snippets more than once, and you won’t need to use all the snippets. Your goal
is to make a class that will compile and run and produce the output listed.
Output:
Code:
public class Puzzle4 {
public static void main(String [] args) {
___________________________________
int y = 1;
int x = 0;
int result = 0;
while (x < 6) {
___________________________
___________________________
y = y * 10;
_________________
}
x = 6;
while (x > 0) {
_________________
result = result + ___________________
}
System.out.println(“result “ + result);
}
}
class ___________ {
int ivar;
________ ______ doStuff(int _________) {
if (ivar > 100) {
return _________________________
} else {
return _________________________
}
}
}
Pool:
BEST OF LUCK

This Content Originally Published by a member of VU Students.

Views: 3820

See Your Saved Posts Timeline

Attachments:

Replies to This Discussion

chk this solution file

Attachments:

Spring 2017 CS506 Assignment 1 Complete Solution is Here. both questions are solved perfectly

Attachments:

Solution :)

Attachments:

CS506 Assignment#01 Complete Solution Spring 2017

Attachments:

Spring 2017 CS506
Assignment No.1

Answer No.1
public class Triangle {
double area;
int height;
int length;

public static void main(String[] args) {

int x = 0;
Triangle[ ] ta = new Triangle[4];
while (x < 4) {
ta[x] = new Triangle();
ta[x].height = (x + 1) * 2;
ta[x].length = x + 4;
ta[x].setArea();
System.out.print("Triangle " + x + ", area");
System.out.println(" = " + ta[x].area);
x = x + 1;
}

int y = x;
x = 27;
Triangle t5 = ta[2];
ta[2].area = 343;
System.out.print("y = " + y);
System.out.println(", t5 area = " + t5.area);
}
void setArea() {
area = (height * length) / 2;
}
}

Answer No.2
public class Puzzle4 {

public static void main(String[] args) {
Puzzle4b[] obs = new Puzzle4b[6];
int y = 1;
int x = 0;
int result = 0;
while (x < 6) {
obs[x]=new Puzzle4b();
obs[x].ivar=y;
y = y * 10;
x=x+1;
}
x = 6;
while (x > 0) {
x=x-1;
result = result + obs[x].doStuff(x);
}
System.out.println("result " + result);
}
}
class Puzzle4b {
int ivar;
public int doStuff(int factor) {
if (ivar > 100) {
return ivar * factor;
} else {
return ivar*(5-factor);
}
}
}

Now which one is correct

RSS

Forum Categorizes

Job's & Careers (Latest Jobs)

Admissions (Latest Admissons)

Scholarship (Latest Scholarships)

Internship (Latest Internships)

VU Study

Other Universities/Colleges/Schools Help

    ::::::::::: More Categorizes :::::::::::

Latest Activity

Member of The Month

1. + ansa

rwp, Pakistan

© 2017   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service