How Many Cigarettes That Can Be Put Inside Pack

Apr 28, 2015

Write a program that accepts as input three positive integers representing the diameter of the cigarettes to be packed and the dimensions of the pack to be used. The required output is the maximum number of cigarettes that can be packed without damaging/re-sizing the cigarettes or packs

NOTE: the diameter of cigarette is 1 and 2 only.

Example: Diameter is: 1 and dimension1: 2 and dimension2: 4
the output is. Maximum number of cigarettes can be put on the pack is 6.
ex.2 diameter is 2 and dimension is 10 and dimension2 is 17
the output is. The maximum number of cigarettes can be put on pack is 40.
ex.3 diameter is 2 and dimension is 5 and dimension2 is 7
the output is. The maximum number of cigarettes can be put on pack is 6.

I just need the formula to get the number of cigarettes that can be put inside on the pack on its dimension.

View Replies


ADVERTISEMENT

Can For Loop Be Nested Inside If?

Mar 6, 2015

Here's what "Why doesn't this work?" question. It concerns a small method which is part of a card game.

I'm trying to check a condition from a section of an array, without a predetermined number of times any given call to this method will require a check. How much of the array I'm checking could vary greatly.

Is it at all possible to nest a for loop yielding a variable number of boolean && conditions inside an if? Am I just missing the right bracketing or is this nesting (if that's the word) even possible in the language?

To clarify, below is broken code. Compiler isn't letting me accomplish this goal as I envision it.

public boolean isFlanking() {
boolean f;
int reach = Math.abs(selectorX - targetX);
if(rival.getDeck()[selectorX].getPile().isEmpty() == true &&

[Code] ....

View Replies View Related

Switch Inside A Do While Loop?

Oct 10, 2014

Basically the problem is I've been trying to loop my switch (if this is even possible) until the user enters a correct number between 1 and 4. But for some reason when the user enters a correct number (1,2,3,4) the loop runs again. Even when the user enters a wrong number the switch ignores the default and repeats what is in the do.

Am I just trying to loop something that cannot be looped or have I gone?

import java.util.Scanner;

class mammals {
int age;
int death;
String name;

[Code].....

View Replies View Related

Replace Unless Inside Quotes?

Aug 24, 2014

Basically, I am trying to write a method that will take a string, a target, and a replacement (a replacement function like string.replace). I want it to replace all instances of target with replacement EXCEPT for instances that occur within single or double quotes.

Example input / output:

this "Wont" be " replaced, be"

call: replace(theString, "replaced", "narf") and replace(theString, "be", "rafn")

output:

this "Wont" rafn " replaced, be"

View Replies View Related

JSF :: Components Inside Tag View

Jun 8, 2014

In some examples I see jsf components inside the tag view, other times dont.

- Is it important to put all jsf components inside "the view" tag?
- What would be the difference not putting them inside this tag?

View Replies View Related

Palindromes Inside Methods

Sep 27, 2014

Write the methods with the following integers:

public static int reverse(int number)
//return true if a palindrome
public static Boolean isPalindrome(int number)

When I compile it says it cannot find symbol "remainder".

import java.util.*;
public class PalindromeInteger
{
public static void main(String[] args)
{
//Create a scanner
Scanner input = new Scanner(System.in);

[code]....

View Replies View Related

Progress Bar Inside Datagrid

Oct 5, 2014

I have a datagrid in which i have to display progress bar with the task completed in %.

For example i have  two fields in a table source count and completion count.

Where source count in 100000 rows and 50000 rows have been inserted.

In another table and status is displayed in the table.

So I need to display in a progress bar that 50% task has been completed.

View Replies View Related

Swing/AWT/SWT :: JPanel Inside A Jframe?

Apr 9, 2014

I have a Jframe and i want to add inside 4 different jpanel.This is easy.

what is difficult is how can i change them dynamically with 4 other new jpanels and 4 other new jpanels?

I have try with BorderLayout but not working.

It's a wizard like but not the same.

I have a jpanel with jbuttons jpanel with a jtable jpanel with textarea and jpanel with jlabels. All this have to change with other 4 jpanels, where to look?

View Replies View Related

JSF :: How To Pass A Value Inside Rich Element

Mar 3, 2014

using richface 4.
#{rich:element('detailsTable'#{id.No})})

showing syntax error.How to pass the value #{id.No} inside rich:element

View Replies View Related

Nesting Interfaces Inside Classes

Jun 20, 2014

When are we allowed to nest interfaces inside a class? Would this be possible? Why or Why not?

View Replies View Related

JTextPane Not Printing Components Inside It

Jun 10, 2014

As I couldn't find a way to do the printing of multiple items on one page, I decided to test out my idea. I found that I could have a table in a JTextPane.

However, whenever I got to print, my table will vanish. It doesn't even need to go to the printer. Just bringing up the print dialog will make it vanish like tax money in D.C.

(Also, I'm not really that familiar with JTextPane and it seems harder than JTextArea. Which part is controlling the font of my regular text by the way? I think it might be tableParagraph but it could also be the base font. I can try and fiddle with both and waste paper but where the font is being set.

Setting the font with setFont() will vanish my table. )

Somehow, I'm thinking that the solution might be JTextPane.setContentType() or setEditorKit() or both. (I"m not that familiar with either, but I fear that it's only being set to handle text, hence any graphics are being lost.)

Here is my code:

import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.text.*;
public class AddingTables {
JTextPane textPane;
private Object[][] rows;
private Object[] colNames;
 
[Code] ....

View Replies View Related

JSP :: Table Inside A Form Not Working?

Oct 8, 2014

I want to put my table inside a form for retrieval purposes (or Am i doing it wrong?) When the table is not within a form, it works perfectly. It displays information the way i wanted.

However, once I put the table inside a form the table doesn't display needed information. Is the problem the html or the jsp code?

Here's my jsp file:

<form action="deletemovie" method="GET" id="deleteForm">
<table class="table table-striped table-responsive table-hover">
<thead>
<tr>
<td>Movie ID</td>
<td>Movie Title</td>

[code].....

View Replies View Related

How To Modify Class File Inside JAR

Oct 28, 2014

I have to modify my ContainerImpl.java inside a .jar file. My modification is in here: [URL] but I do not know how can I modify it

View Replies View Related

How To Print Out All Elements Inside ArrayList

Oct 5, 2014

When this program runs it gives me

workbook.Contact@46e5590e
Number of contact: 1

The number of Contact that I input is just one when I run the program so the Number of contacts: 1 is correct, but it gives me workbook.Contact@46e5590e instead of printing out all the contacts stored inside the Contact class. Yes I do loop through the ArrayList and I also have a method inside the Contact class, the printNameAndPhone(), which prints out the name as well as the phone number but how do I incorporate the printNameAndPhone() method (located in the Contact class) inside the print() method (located inside the AddressBook class)???

Basically I'm asking how to access all the elements in the ArrayList<Contact> addressBook = new ArrayList<>();??My main class AddressBook

package addressbook;
import java.util.Scanner;
import java.util.ArrayList;
public class AddressBook {

[code]....

View Replies View Related

Servlets :: Writing A File Inside WEB-INF?

Nov 29, 2014

I want a servlet to write a file inside WEB-INF folder

I tried these things

File file =new File("feedback.txt");

or

File file =new File("/feedback.txt");

or

File file =new File("WEB-INF/feedback.txt");

View Replies View Related

If Statement Won't Work Inside A While Loop

Dec 12, 2014

I made this calculator in C++ and it worked wonderful so I decided to make it in java. When I run the program it gives me no errors but my if statements inside my while loop don't work

import java.util.Scanner;
public class ohmlaw {
public static void main(String args[]) {
float current;
float resistance;
float voltage;
String calchoice = new String();
Scanner cc = new Scanner(System.in);

[code]....

View Replies View Related

Objects Inside Class Declaration

Apr 13, 2014

Ok say you have

public class MyClass {
private int x = 5;
Object myObject = new Object();
public MyClass(){
}
}

When would the myObject be created? Before or after the constructor? And does this mean you can't pass
this into the parameters of that object?

View Replies View Related

Servlets :: Components Inside Web Server?

Feb 1, 2014

If we have request which hit the server, before it reaches servlet or the response going to send the browsers, through how many components it pass through (or the process flow).

View Replies View Related

JSF :: Datatable Not Editable Inside Of A Form

Oct 11, 2014

When I have a datatable of primefaces with paginator and its only readable and not editable, its not needed to be inside of a form, right? although I have seen it many times inside of it

View Replies View Related

How To Get Data Inside Table Row When That Row Is Clicked

Dec 19, 2014

I am using netbeans swing to do my little project . I have one table which is populated by data from a database. I also have another table which should be populated when a user selects a certain row in the first table.Both table have only one column. The logic is when a user selects on row 1,the data in that row should be obtained and should be used to search for certain entities in the database which are returned and used to populate table 2.So after a user selects row1 and decides to select row2 the second table should be updated accordingly. I have attached the java file

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package UI;

import java.awt.CardLayout;
import java.sql.SQLException;
import java.util.logging.Level;

[Code] ....

View Replies View Related

Object Created Inside Switch

Mar 2, 2014

I have create as short example which contains two classes Cat and Dog followed by a switch statement in the main method.

Class Cat

public class Cat {
private String name;
//Setter
public void setName(String pName)
{name = pName;}
//Getter
public String getName()
{return name;}
// Constructor
public Cat(String catName)
{name = catName;}

[code]....

My Issue is that after creating the objects within the switch statement, is there a way to return the objects back to the main method once created within the switch ?

View Replies View Related

Creating Class Inside A Interface

Jun 22, 2014

I am not able to understand how we are able to create an object of static inner class defined inside an interface .

interface outer {
class inner {
void disp() {
System.out.println("inside disp");

[Code] ....

output:

inside disp

How am i able to create a new object for static class?

View Replies View Related

Switch Statement Inside While Loop

May 5, 2015

cannot break from while loop. Whenever I am trying to exit from startCustomerManagement-> backEnd() -> mainScreen()..It gets stuck between mainScreen and backEnd screen. However I can exit from backEnd()->startCustomerManagement() screen

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication19;
import java.io.BufferedReader;

[code]...

View Replies View Related

Declare String Inside Of Loop - Use It Outside

Apr 26, 2015

I'm trying to code a little text RPG. I've made a little "personality test", with 4 questions (answers a b c), where every letter stands for a type of personality. The analysis of the result is simple counting of the answers, if you have 3 answers a (4 questions), then a has won. If 2 on a, and 2 on b, a simple Random method shows weather result a or b.

Now... the test should give you a "partner" (imagine the pokemon game with 3 different starter pokemon). I have now 3 string variables, like 3 different partners. They are all declared somewhere outside, but i only need one later.

Like...the test is completed, you have your partner and how can i make now that the program is just showing me my partner? Like...when i type " System.out.println(partner); " (outside of the test loop! ) that i only get the one i got through the test?

I was trying to declare in every loop the partner String with every result. But outside the loop java isn't recognising that String, bcs...ofc...it was declared for the loop. So i had in every if or else if clause a " String partner = anwsA;" and answB and answC, thats why i cant declare them outside.

Short: i need a partner String variable that could have 3 possible results... i jut need one

I'm using Eclipse Luna 4.4

View Replies View Related

Put Answer Of JCheckBox Inside Of JTextArea

Sep 17, 2014

I would like to put the answer of JCheckBox inside of a JTextArea. How to call the answer of JCheckBox if its check the response should be Yes if its unchecked the response should be No, and the yes/no answer should be appear inside JTextArea. But my problem is inside the JTextArea the answer from a JTextField and JComboBox is also there, and they should be appear in a parallel. I attached the physical appearance of the GUI.

Attached image(s)

View Replies View Related

Polymorphic Method Inside Constructor

Aug 1, 2014

Why in this code testSon class void display() method is called instead of testFather class void display()

class testFather
{
void display() {
System.out.println("This is testFather class");
}
testFather() //testFather constructor {
display();

[Code] .....

Output : This is testSon class /* why not This is testFather class*/
This is cons of testSon class

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved